MySQL,插入记录时中文字段报错:1366 Incorrect string value

问题:

** MySQL Workbench 中错误提示:**1366 Incorrect string value: '\xE5\xBC\xA0\xE4\xB8\x89' for column 'sname' at row 1

解决方法:

查看数据库、表、中文列、连接 url,把所有字符集统一为 UTF8,即解决中文插入报错问题。

# 查看数据库字符集
show create database imooc_sh;

# 查看数据表字符集
show create table students;

# 查看表中列字符集,如下图:
MySQL,插入记录时中文字段报错:1366 Incorrect string value_第1张图片
Workbench 中查看与修改字符集

注:此问题通常会出现在如 Hibernate 生成表结构等。

参考链接:http://blog.csdn.net/hongweigg/article/details/46354647

你可能感兴趣的:(MySQL,插入记录时中文字段报错:1366 Incorrect string value)