Home  >  Article  >  Database  >  解决MySQL中文乱码有关问题

解决MySQL中文乱码有关问题

WBOY
WBOYOriginal
2016-06-07 16:26:531192browse

解决MySQL中文乱码问题 决解乱码费了我好些时间啊! 乱码原因有 1.mysql未设置为支持汉字 2.没有发送头信息 3.使用的编译器不符合相应的编码 决解的方法是 在mysql里 我用的是Wanmp Server 1.在mysql目录下找到my.ini,在[client]新增default-character-set=u

解决MySQL中文乱码问题
决解乱码费了我好些时间啊!
乱码原因有
1.mysql未设置为支持汉字
2.没有发送头信息
3.使用的编译器不符合相应的编码


决解的方法是
在mysql里
我用的是Wanmp Server
1.在mysql目录下找到my.ini,在[client]新增default-character-set=utf8
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
default-character-set=utf8 
2.在[mysld]:增加
character-set-server=utf8 
collation-server=utf8_general_ci 
3.重启mysql服务

在代码里
 
header("Content-Type:text/html;charset=utf-8");//原来这个是那么的重要,


在编译器里

设置为utf-8编写


由于windows终端是gbk编码的,所以不能用它来输入和显示

Statement:
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