Home > Database > Mysql Tutorial > Solution to the problem that the MySQL encoding is different from the encoding when creating the table

Solution to the problem that the MySQL encoding is different from the encoding when creating the table

黄舟
Release: 2016-12-16 11:19:13
Original
1500 people have browsed it

First, let’s take a look at a specific example of the error:

Illegal mix of collations (gbk_chinese_ci,IMPLICIT)

and (gbk_bin,IMPLICIT) forOperation '=',

SQL State: HY000, Error Code: 1267


Cause:


The encoding of the database is different from the encoding when creating the table;



Processing method:


If the encoding set when installing MySQL is jbk, then create the table You can use the following method to handle it:


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;




another A solution:


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

) ;

The above is the solution to the problem that the MySQL encoding is different from the encoding when creating the table. For more related articles, please Follow the PHP Chinese website (m.sbmmt.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