MySQL Server and UTF-8 Defaults

Updated . Posted . Visible to the public.

Unless all MySQL server defaults are set to UTF-8, mysqldump encodes UTF-8 characters incorrectly and only outputs correct UTF-8 when you switch to Latin 1 (!). Also you need to setup charset and collation manually for each new database.

To prevent this, make sure your /etc/mysql/my.cnf looks like this:

[mysqld]
default-character-set = utf8mb4
collation-server = utf8mb4_unicode_ci

[mysql]
default-character-set=utf8mb4

After that do

sudo /etc/init.d/mysql restart
Profile picture of Martin Straub
Martin Straub
Last edit
Daniel Straßner
License
Source code in this card is licensed under the MIT License.
Posted by Martin Straub to makandra dev (2010-08-25 14:33)