First, let's look at an error example:
Illegal mix of collations (gbk_chinese_ci,IMPLICIT)
and (gbk_bin,IMPLICIT) for operation '=',
SQL State: HY000, Error Code: 1267
Reason:
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, you can use the following method when creating a table:
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;
You can also use the following method:
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`)
) ;