mysql 支持中文,防止程序乱码的方法

1. 查看你的mysql的字符设置

mysql> show variables like '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/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.01 sec)

 2. 之前我的character_set_server,character_set_database是latin1

可以再my.cnf中的[mysqld]中添加

character_set_server=utf8(网上有人说是添加 default-character-set=utf8,我试过后发现mysql无法启动了,不知道是不是版本的问题

 

posted @ 2014-04-27 15:31  马僧  阅读(245)  评论(0编辑  收藏  举报