Home > Database > Mysql Tutorial > 解决Mysql乱码问题_MySQL

解决Mysql乱码问题_MySQL

WBOY
Release: 2016-06-01 13:44:38
Original
942 people have browsed it

bitsCN.com

 

折腾了半天,在网上找了半天,终于解决了Mysql的乱码问题!

 

系统是Fedora15,通过sudo yum install mysql-server mysql-client后,修改/etc/my.cnf

 

在[mysqld]下添加default-character-set=utf8,重启mysql,发现报错,查看日志,

 

得知不识别default-character-set 配置项,杯具啊,在网上查,都是用这个方法啊!!

 

因为我通过mysql> show variables like 'character%';查看得知,只有character_set_server 这一项不为utf8,

 

于是在网上找这个,终于无意中在一篇文章中看到有网友在[mysqld]下添加: character_set_server=utf8 的,

 

这才恍然醒悟!!!

 

此外,其他关于其他各项的字符集修改,都跟上面差不多。

 

以下是修改数据库、表、字段编码的命令:

 

alter database databasename character set utf8;

 

alter table tablename convert to character set utf8;

alter table `tablename` change  `colname` `colname` varchar(200) character set utf8 not null;

摘自:Hymer的专栏

bitsCN.com
Related labels:
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