Blogger Information
Blog 12
fans 1
comment 1
visits 19095
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Mysql数据库乱码问题
黄小凡的博客
Original
864 people have browsed it

有的时候数据库一直有乱码,这个时候就需要检查数据库的编码问题了,登录mysql,查看当前编码

show variables like "%char%";

1.png

这是我刚安装完的默认mysql 字符编码,windows下进入mysql的配置文件my.ini修改,Linux下进入my.cnf

vi  /etc/my.cnf

SET NAMES 'charset_name'

SET NAMES 'x'语句与这三个语句等价:

mysql>SETcharacter_set_client = x;

mysql>SETcharacter_set_results = x;

mysql>SETcharacter_set_connection = x;

再加入以下三行

[client]  
default-character-set=utf8  
/*[mysqld]*/  
character-set-server=utf8
default-character-set=utf8

保存退出重启mysql即可

service mysqld restart

1.png

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!