Home > Database > Mysql Tutorial > 实例讲解MySQL字符集出错的解决方法

实例讲解MySQL字符集出错的解决方法

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 16:17:31
Original
1035 people have browsed it

错误如下: Illegal mix of collations (gbk_chinese_ci,IMPLICIT) and (gbk_bin,IMPLICIT) for operation '=', SQL State: HY000, Error Code: 1267 错误原因: 数据库的编码与建表时的编码不一样; 处理方法: 如果安装MySQL时设置的编码为jbk,那么在

  错误如下:

  Illegal mix of collations (gbk_chinese_ci,IMPLICIT)

  and (gbk_bin,IMPLICIT) for operation '=',

  SQL State: HY000, Error Code: 1267

  错误原因:

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

  处理方法:

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

  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;

  或者:

  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 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