How to configure UTF8 default collation in MySQL?

How to configure MySQL to use UTF8 (UTF8_general_ci) as default collation in MySQL for the new databases?

Step 1:
Add in in /etc/my.cnf the following lines:


[mysql]
default-character-set=utf8
[mysqld]
collation_server=utf8_unicode_ci
character_set_server=utf8
default-character-set=utf8
init_connect='SET collation_connection = utf8_general_ci'
init_connect='SET NAMES utf8'

Step 2: Restart MySQL
/etc/init.d/mysql restart

Leave a Reply