错误:
ERROR 1366 (HY000): Incorrect string value: '\xB3\xA4\xC9\xB3' for column
解决:
使用命令查看数据库的字符编码: mysql> show variables like ‘char%’;
将MYSQL数据库同一设置成: gbk格式, 命令如下:
MYSQL>set character_set_client = 'gbk' ;
MYSQL>set character_set_connection = 'gbk' ;
MYSQL>set character_set_results= 'gbk' ;
MYSQL>set character_set_server= 'gbk' ;
MYSQL>set character_set_database= 'gbk' ;
完成之后,执行mysql> show variables like ‘char%’;
然后修改对应的数据表的字符编码:
mysql> alter table teacher modify depart varchar(30) character set gbk;
Query OK, 0 rows affected (0.02 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> alter table student modify ssex varchar(30) character set gbk;
Query OK, 1 row affected (0.04 sec)
再重启mysql,就可以输入中文不报错了