Home  >  Article  >  Backend Development  >  mysql 字符集有关问题

mysql 字符集有关问题

WBOY
WBOYOriginal
2016-06-13 10:57:061051browse

mysql 字符集问题
网页全部utf-8,mysql安装时是用的utf8,网页中设置了mysql_query("set names utf8");
但是无法对mysql添加中文数据,改成mysql_query("set names gbk");可以,返回的又是一堆乱码
在不改变编码方式的前提下有什么好办法吗?

------解决方案--------------------
无法添加的情况是 添加后空白? 数据库/表设置成utf8
------解决方案--------------------
把你的php文件也改为utf-8,然后mysql_query("set names utf8"); 应该不会有问题了。
------解决方案--------------------
最好改下程序,将你的程序代码改为数据库编码。这样不会导致数据出现错误!
------解决方案--------------------
你的MySQL里的my.ini里
分别在[client][mysql]和[mysqld]三处下面的
default-character-set=
也是设置utf8了吗?

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