时间:2021-07-01 10:21:17 帮助过:12人阅读
环境:Centos6.3、mysql5.1Centos6.3在上安装mysqlclient和server之后,出现乱码,不得不修改编码。注意:关于utf8和gbk的区别详细见:linux中文乱码问题解决办
注意:
解决步骤:
[root@Web_Mysql ~]# find / -iname "*.cnf" -print
/usr/share/mysql/my-huge.cnf
/usr/share/mysql/my-small.cnf
/usr/share/mysql/my-innodb-heavy-4G.cnf
/usr/share/mysql/my-medium.cnf
/usr/share/mysql/my-large.cnf
/usr/share/doc/mysql-server-5.1.61/my-huge.cnf
/usr/share/doc/mysql-server-5.1.61/my-small.cnf
/usr/share/doc/mysql-server-5.1.61/my-innodb-heavy-4G.cnf
/usr/share/doc/mysql-server-5.1.61/my-medium.cnf
/usr/share/doc/mysql-server-5.1.61/my-large.cnf
/etc/pki/tls/openssl.cnf
/etc/my.cnf
找到之后,复制一个出来
[root@Web_Mysql ~]# cp /usr/share/doc/mysql-server-5.1.61/my-medium.cnf /etc/my.cnf
[root@Web_Mysql ~]# vim /etc/my.cnf
default-character-set=utf8
default-character-set=utf8
[root@Web_Mysql ~]# /etc/rc.d/init.d/mysqld restart
[root@Web_Mysql ~]#service mysqld restart
[root@Web_Mysql ~]# mysql -u root -p
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.00 sec)
mysql>
配置完成!
本文出自 “运维IT” 博客,网站空间,网站空间,请务必保留此出处
,香港虚拟主机