Home > Database > Mysql Tutorial > body text

CentOS(Linux)中解决MySQL乱码

WBOY
Release: 2016-06-07 17:40:51
Original
970 people have browsed it

环境: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” 博客,网站空间,网站空间,请务必保留此出处

,香港虚拟主机
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template