ERROR 1366 (HY000): Incorrect string value: '\xE4\xB8\xAD\xE5\x9B\xBD' for column 'tname' at row 1

来源:互联网 发布:python 读取配置文件 编辑:程序博客网 时间:2024/05/15 02:45

在mysql中插入中文字段的时候会提示下面报错


mysql> insert into tutors values(32,'中国','M',21);

ERROR 1366 (HY000): Incorrect string value: '\xE4\xB8\xAD\xE5\x9B\xBD' for column 'tname' at row 1


这是由于没有设置编码


mysql> set names latin1;
Query OK, 0 rows affected (0.00 sec)

(latin1可以用gdk等编码)

0 0