Home > Database > Mysql Tutorial > body text

如何解决MySQL 5.5的中文乱码问题

WBOY
Release: 2016-06-07 16:46:37
Original
1050 people have browsed it

1,/etc/my.cnf 默认是少配置的。你可以cp /usr/share/mysql/my-large.cnf /etc/my.cnf. 2.打开my.cnf文件,增加如下参数: [c

1,/etc/my.cnf 默认是少配置的。你可以cp /usr/share/mysql/my-large.cnf /etc/my.cnf. 

2.打开my.cnf文件,,增加如下参数: [client]:增加default-character-set=utf8参数 

以下是代码片段:

[client]
#password = [your_password]
port = 3306
socket = /tmp/mysql.sock
default-character-set=utf8

  [mysqld]:增加如下3个参数 

以下是代码片段:

[mysqld]
default-storage-engine=INNODB
character-set-server=utf8
collation-server=utf8_general_ci
# generic configuration options
port = 3306
socket = /tmp/mysql.sock

  3.设置完成后,重启下mysql服务

  4.连接上你的数据库之后,输入命令:SHOW VARIABLES LIKE '%char%';即可查看到现在你的数据库所使用的字符集了:

如何解决MySQL 5.5的中文乱码问题

linux

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!