前段时间给后台系统开发相应的配置页面,在显示中文时出现了乱码,下面说说怎么解决。
1、查看mysql编码:
mysql> show variables like '%character%';
+--------------------------+-----------------------------------------------+
| Variable_name | Value |
+--------------------------+-----------------------------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/mysql-5.0.67/share/mysql/charsets/ |
+--------------------------+-----------------------------------------------+
其中,各个字段含义如下:
– character_set_server:默认的内部操作字符集
– character_set_client:客户端来源数据使用的字符集
– character_set_connection:连接层字符集
– character_set_results:查询结果字符集
– character_set_database:当前选中数据库的默认字符集
– character_set_system:系统元数据(字段名等)字符集
2、修改/etc/my.cnf:
在[client]和[mysqld]下分别加上:default-character-set = utf8
重启mysql即可
3、如果是在终端上直接查看,还要把终端编码类型改为utf8
阅读(1451) | 评论(0) | 转发(0) |