解决mysql中文编码问题。
ERROR 1366 (HY000):Incorrect string value: ‘\xD5\xC5\xC0\xCF\xCA\xA6’ for column ‘teacher_name’ at
1、把utf8换成gbk;
图文展示:
建表:
出现错误:
查看数据库的字符编码:
修改:
mysql> set character_set_client = ‘gbk’ ;
Query OK, 0 rows affected (0.00 sec)
mysql> set character_set_connection = ‘gbk’ ;
Query OK, 0 rows affected (0.00 sec)
mysql> set character_set_results= ‘gbk’ ;
Query OK, 0 rows affected (0.00 sec)
mysql> set character_set_server= ‘gbk’ ;
Query OK, 0 rows affected (0.00 sec)
mysql> set character_set_database= ‘gbk’ ;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> show variables like ‘char%’;
修改相关属性(字段名)的编码:
插入数据: