Home  >  Article  >  Database  >  快速解决MySQL数据库字符集的出错问题_MySQL

快速解决MySQL数据库字符集的出错问题_MySQL

WBOY
WBOYOriginal
2016-06-01 14:04:39962browse
 

出现错误的示例:

 

<ccid_code></ccid_code>Illegal mix of collations (gbk_chinese_ci,IMPLICIT) 
and (gbk_bin,IMPLICIT) for operation '=', 
SQL State: HY000, Error Code: 1267

原因:

数据库的编码与建表时的编码不一样;

处理方法:

如果安装MySQL时设置的编码为jbk,那么建表时可以用下面的方法处理:

 

<ccid_code></ccid_code>CREATE TABLE `teachers` (
id` int(11) NOT NULL default '0',
name` varchar(20) default NULL,
password` varchar(20) default NULL,
department_id` int(11) default NULL,
PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=gbk;

或者用下面的方法:

 

<ccid_code></ccid_code>CREATE TABLE `teachers` (
id` int(11) NOT NULL default '0',
name` varchar(20) default NULL,
password` varchar(20) default NULL,
department_id` int(11) default NULL,
PRIMARY KEY  (`id`)
) ;
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