centos 5.5 mysql5.5 乱码
1. 找到mysql的配置文件,拷贝到etc目录下,第一步很重要
使用find命令查找cnf文件。记得不要去找my.cnf因为它不一定存在,而应该找*.cnf。
[root@linuxserver classes] find / -iname *.cnf -print
/root/Desktop/mysql-5.0.56/mysql-test/std_data/ndb_config_mycnf1.cnf
/root/Desktop/mysql-5.0.56/mysql-test/std_data/bug15328.cnf
/root/Desktop/mysql-5.0.56/mysql-test/std_data/ndb_config_mycnf2.cnf
/etc/my.cnf
/etc/pki/tls/openssl.cnf
/usr/share/mysql/my-medium.cnf
/usr/share/mysql/my-large.cnf
/usr/share/mysql/my-small.cnf
/usr/share/mysql/my-huge.cnf
/usr/share/mysql/my-innodb-heavy-4G.cnf
/usr/share/doc/MySQL-server-community-5.0.92/my-medium.cnf
/usr/share/doc/MySQL-server-community-5.0.92/my-large.cnf
/usr/share/doc/MySQL-server-community-5.0.92/my-small.cnf
/usr/share/doc/MySQL-server-community-5.0.92/my-huge.cnf
/usr/share/doc/MySQL-server-community-5.0.92/my-innodb-heavy-4G.cnf
找到之后,复制一个出来
cp /usr/share/doc/MySQL-server-community-5.0.92/my-large.cnf
/etc/my.cnf
2. 打开my.cnf修改编码
vi /etc/my.cnf
在[mysqld]下添加 是mysqld,而不是mysql下!
character_set_server=utf8
重启mysql
service mysqld restert
4.登录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/ |