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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 14:04:39
Original
1024 people have browsed it
 

出现错误的示例:

 

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

原因:

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

处理方法:

如果安装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;
Copy after login

或者用下面的方法:

 

<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`)
) ;
Copy after login
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