当前位置:Gxlcms >
数据库问题 >
mysql 插入中文时出现ERROR 1366 (HY000): Incorrect string value: '\xC0\xEE\xCB\xC4' for column 'usern ame' at row 1
mysql 插入中文时出现ERROR 1366 (HY000): Incorrect string value: '\xC0\xEE\xCB\xC4' for column 'usern ame' at row 1
时间:2021-07-01 10:21:17
帮助过:5人阅读
2‘ ,
‘
李四
‘ , ‘1980 12-
31‘ , ‘male
‘ , ‘beijing
‘);
ERROR
1366 (HY000): Incorrect
string value:
‘\xC0\xEE\xCB\xC4‘ for column
‘usern
ame
‘ at row 1
mysql>
select *
from user;
Empty set (
0.00 sec)
mysql>
set names gbk;
Query OK, 0 rows affected (
0.00 sec)
mysql> insert into user(id , username , birthday, sex, address) values(
‘2‘ ,
‘
李四
‘ , ‘1980 12-
31‘ , ‘male
‘ , ‘beijing
‘);
Query OK,
1 row affected (
0.10 sec)
mysql>
select *
from user;
+----+----------+------------+------+---------+
| id | username | birthday | sex | address |
+----+----------+------------+------+---------+
|
2 | 李四 |
1980 12-
31 | male | beijing |
+----+----------+------------+------+---------+
1 row
in set (
0.00 sec)
4 总结
当出现乱码,就是编码的问题,可以尝试设置数据库的编码(set nams gbk)。
mysql 插入中文时出现ERROR 1366 (HY000): Incorrect string value: '\xC0\xEE\xCB\xC4' for column 'usern ame' at row 1
标签: