diff --git a/tasks/mysql.yml b/tasks/mysql.yml index 52cf4a9..111c57d 100644 --- a/tasks/mysql.yml +++ b/tasks/mysql.yml @@ -11,5 +11,7 @@ - name: mysql database mysql_db: name: "{{nextcloud_database_name}}" + encoding: utf8mb4 + collation: utf8mb4_unicode_ci state: present delegate_to: "{{ nextcloud_database_host }}" diff --git a/templates/config.php.j2 b/templates/config.php.j2 index cbaa254..4874c67 100644 --- a/templates/config.php.j2 +++ b/templates/config.php.j2 @@ -108,6 +108,38 @@ $CONFIG = array( */ 'installed' => false, +/** + * During setup, if requirements are met (see below), this setting is set to true + * and MySQL can handle 4 byte characters instead of 3 byte characters. + * + * If you want to convert an existing 3-byte setup into a 4-byte setup please + * set the parameters in MySQL as mentioned below and run the migration command: + * ./occ db:convert-mysql-charset + * The config setting will be set automatically after a successful run. + * + * Consult the documentation for more details. + * + * MySQL requires a special setup for longer indexes (> 767 bytes) which are + * needed: + * + * [mysqld] + * innodb_large_prefix=ON + * innodb_file_format=Barracuda + * innodb_file_per_table=ON + * + * Tables will be created with + * * character set: utf8mb4 + * * collation: utf8mb4_bin + * * row_format: compressed + * + * See: + * https://dev.mysql.com/doc/refman/5.7/en/charset-unicode-utf8mb4.html + * https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_large_prefix + * https://mariadb.com/kb/en/mariadb/xtradbinnodb-server-system-variables/#innodb_large_prefix + * http://www.tocker.ca/2013/10/31/benchmarking-innodb-page-compression-performance.html + * http://mechanics.flite.com/blog/2014/07/29/using-innodb-large-prefix-to-avoid-error-1071/ + */ +'mysql.utf8mb4' => true, /** * User Experience