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 (www.php.cn)!