linux修改mysql字符集编码
摘要:本文适用于mysql5.5mysql5.6其他版本未测试mysql-u帐号-p密码登录mysqlmysql>SHOWVARIABLESLIKE'character%';查看当前字符集编码方式MySQL[(none)]>SHOWVARIABLESLIKE'cha
本文适用于mysql5.5mysql5.6其他版本未测试
mysql-u帐号-p密码登录mysql
mysql>SHOWVARIABLESLIKE'character%';查看当前字符集编码方式
MySQL[(none)]>SHOWVARIABLESLIKE'character%';
+--------------------------+----------------------------------+
|Variable_name|Value|
+--------------------------+----------------------------------+
|character_set_client|latin1|
|character_set_connection|latin1|
|character_set_database|gbk|
|character_set_filesystem|binary|
|character_set_results|latin1|
|character_set_server|gbk|
|character_set_system|utf8|
|character_sets_dir|/usr/local/mysql/share/charsets/|
+--------------------------+----------------------------------+
8rowsinset(0.01sec)
我这里是gbk,现在改成utf8,反之同理
编辑/etc/my.cnf文件
在[client]字段下增加default-character-set=utf8
在[mysqld]字段下增加character-set-server=utf8
在[mysql]字段下增加default-character-set=utf8
注:在mysql字段增加这段后,发现mysql重启报错,于是把这段去掉,mysql就正常了,但是后来我又继续尝试了次,就没有报错,不知道什么问题。
修改完成后需要重启mysql服务!
然后在#mysql-u帐号-p密码登录mysql
mysql>SHOWVARIABLESLIKE'character%';
MySQL[(none)]>SHOWVARIABLESLIKE'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/local/mysql/share/charsets/|
+--------------------------+----------------------------------+
8rowsinset(0.01sec)
此时数据库编码改成utf8
用云栖社区APP,舒服~