默認登錄mysql之後show variables like
mysql> show variables like
+
| Variable_name | Value |
+
| character_set_client | latin
| character_set_connection | latin
| character_set_database | latin
| character_set_filesystem | binary |
| character_set_results | latin
| character_set_server | latin
| character_set_system | utf
| character_sets_dir | /usr/share/mysql/charsets/ |
+
使用find命令查找cnf文件
[root@linuxserver classes] find /
/usr/share/doc/mysql
/usr/share/doc/mysql
/usr/share/doc/mysql
/usr/share/doc/mysql
/usr/share/doc/mysql
/usr/share/texmf/web
/usr/share/texmf/web
/usr/share/texmf/web
/usr/share/texmf/tex/jadetex/f
/usr/share/ssl/f
找到之後
cp /usr/share/doc/mysql
vi /etc/f
在[client]下增加default
在[mysqld]下增加default
同時加上init_connect=
重新啟動mysql
mysql> show variables like
+
| Variable_name | Value |
+
| character_set_client | utf
| character_set_connection | utf
| character_set_database | utf
| character_set_filesystem | binary |
| character_set_results | utf
| character_set_server | utf
| character_set_system | utf
| character_sets_dir | /usr/share/mysql/charsets/ |
+
即使做了以上修改如果直接數據庫再創建表
創建數據庫的時候指明默認字符集為utf
create database test default character set utf
From:http://tw.wingwit.com/Article/program/MySQL/201311/29441.html