《Mysql必读Linux下MySQL 5.5/5.6的修改字符集编码为UTF8的方法》要点:
本文介绍了Mysql必读Linux下MySQL 5.5/5.6的修改字符集编码为UTF8的方法,希望对您有用。如果有疑问,可以联系我们。
一、登录MySQL查看用SHOW VARIABLES LIKE ‘character%'; 下字符集,显示如下:MYSQL必读
+--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+
character_set_database和character_set_server的默认字符集还是latin1.MYSQL必读
二、最简单的完美修改方法,修改mysql的my.cnf文件中的字符集键值(注意配置的字段细节):MYSQL必读
1、在[client]字段里加入default-character-set=utf8,如下:MYSQL必读
[client] port = 3306 socket = /var/lib/mysql/mysql.sock default-character-set=utf8
2、在[mysqld]字段里加入character-set-server=utf8,如下:MYSQL必读
[mysqld] port = 3306 socket = /var/lib/mysql/mysql.sock character-set-server=utf8
3、在[mysql]字段里加入default-character-set=utf8,如下:MYSQL必读
[mysql] no-auto-rehash default-character-set=utf8
修改完成后,service mysql restart重启mysql服务就生效.注意:[mysqld]字段与[mysql]字段是有区别的.这点在网上没人反馈过.MYSQL必读
使用SHOW VARIABLES LIKE ‘character%';查看,发现数据库编码全已改成utf8.MYSQL必读
+--------------------------+----------------------------+ | 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/ | +--------------------------+----------------------------+
以上这篇Linux下MySQL 5.5/5.6的修改字符集编码为UTF8的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持维易PHP.MYSQL必读
转载请注明本页网址:
http://www.vephp.com/jiaocheng/3828.html