标签:
1、在/etc/my.cnfig添加这么几行
[mysql] default-character-set=utf8
[mysqld] character-set-server=utf8
[client] default-character-set=utf8
一般情况下添加上述三个就可以,我们可以使用这样的命令查看
mysql> show variables like ‘character%‘; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | utf8 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+
如果结果里除了character_set_filesystem 不是utf8的话,这时候需要执行这样的命令
set character_set_server=utf8;
哪个不是utf8就set哪一个。待所有的都是utf-8后,重启下mysql服务就可以了。
service mysql restart
标签:
原文地址:http://my.oschina.net/u/933928/blog/497014