MySql 5 basic handling of utf-8 database

1. Setup default mysql character set
modify mysql.cnf
[client]
default_character_set=utf8
[mysqld]
default-character-set=utf8
character-set-server = utf8
collation-server = utf8_general_ci
[mysql]
default_character_set=utf8

You will need to setup apache too if your website need utf-8
modify \apache\conf\extra\httpd-languages.conf
find :
AddLanguage zh-CN .zh-cn
AddLanguage zh-TW .zh-tw
add :
AddLanguage UTF-8 .utf8
find :
LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW
change :
LanguagePriority UTF-8 en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW
add :
DefaultLanguage UTF-8
AddDefaultCharSet UTF-8

2. Check database character set
mysql>SHOW VARIABLES LIKE ‘character_set%’;
mysql>SHOW VARIABLES LIKE ‘collation%’;
Change database character set
mysql>SET NAMES utf8;
mysql>SET CHARACTER SET utf8;
mysql>SET GLOBAL/SESSION character_set_XXX=utf8

3. Create utf-8 database
mysql>create database db_name character set utf8;

4. Restore utf-8 dump
mysql -uroot dbname < dump.sql –default-character-set=utf8

Remark: please note that mysql start supporting utf-8 from 5.0

Advertisements

One thought on “MySql 5 basic handling of utf-8 database

  1. Pingback: MySql 5 дээр utf-8 тэмдэгтийн кодчлолыг тохируулах « Xocoo’s Weblog

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s