Posted by zuzhihui in Linux技术 on 2008/06/21 with No Comments
MySQL的中文编码问题最简单的解决方案是:修改mysql的配置文件/etc/mysql/my.cnf (在CentOS下是/etc/my.cnf),在[mysqld] 和 [client]段都加入如下指令:
default-character-set=utf8
注意:如果没有[client]段,就手工加入[client]段。然后重新启动MySQL即可。验证一下是否生效:
mysql> show variables like 'char%';
-------------------------- ----------------------------
| 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/ |
-------------------------- ----------------------------
8 rows in set (0.00 sec)
mysql>
这样新建立的数据库缺省就是UTF8编码了。
要发表评论,您必须先登录。
近期评论