Home > Database > Mysql Tutorial > body text

修改mysql 表的字符编码_MySQL

WBOY
Release: 2016-05-30 17:11:18
Original
1025 people have browsed it

在select进行中文查询的时候报了如下的错误

 

ERROR 1267 (HY000): Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation ‘=‘

 

查看一下表的编码

 

show create table t_user_friend;

 

发现其是latin1编码的,需将其转成utf8

 

命令如下

 

alter table t_user_friend convert to character set utf8;

 

 

 

当然还可以设置mysql的客户端和服务器的默认编码

 

vi /etc/mysql/my.conf

 

 

 

在[mysql] 下面 添加  default-character-set=utf8

 

 

 

在[mysqld] 下面添加 

 

character-set-server=utf8

 

collaction-server = utf8-greneral-cli

 

 

 

修改完后重启mysql server

 

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