Adding Multi-byte UTF-8 support in Drupal 7
Written by Mark Chambers onYou need at least version 5.5.3 of MySQL. Check your version number before you proceed:
mysql --version
1: Edit MySQL settings
1.1: Edit your MySQL config file:
sudo vi /etc/mysql/my.cnf
1.2: Add these lines in the [mysqld]
section:
innodb_large_prefix=true
innodb_file_format=barracuda
innodb_file_per_table=true
1.3: To load the new settings, restart MySQL:
sudo service mysql restart
2: Convert database
Before you begin:
- You will need
drush
installed on your server. Click here for instructions - Make backups of your databases
2.1: Download script
drush @none dl utf8mb4_convert-7.x
2.2: Go to your Drupal root
cd /var/www/html
2.3: Put your site into maintenance mode
drush vset maintenance_mode 1
2.4: Run the script
drush utf8mb4-convert-databases
2.5: Update settings.php
Open settings.php
in your favorite text editor:
vi /var/www/html/sites/default/settings.php
Add these lines to your database array:
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
It should look like this:
$databases['default']['default'] = array(
'driver' => 'mysql',
'database' => 'databasename',
'username' => 'username',
'password' => 'password',
'host' => 'localhost',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
);
2.6: Take your site out of maintenance mode:
drush vset maintenance_mode 0