欢迎来到cool的博客
7

Music box

Click to Start

点击头像播放音乐
新博客链接

bug : mysql table不能输入中文

mysql> INSERT INTO students values (1, "李明");

ERROR 1366 (HY000): Incorrect string value: '\xE6\x9D\x8E\xE6\x98\x8E' for column 'name' at row 1

 

解决方法: 

This is because of incompatible character set and collation defined on table's column.

Try changing character set of your table or column to UTF8.

ALTER TABLE table_name CONVERT TO CHARACTER SET utf8;

or
ALTER TABLE table_name MODIFY col VARCHAR(255) CHARACTER SET utf8;

在mysql中输入:

 

mysql> ALTER TABLE students CONVERT TO CHARACTER SET utf8; 

返回列表