Home >Database >Mysql Tutorial >ERROR 1366 (HY000): Incorrect string value:’XXX’ for column

ERROR 1366 (HY000): Incorrect string value:’XXX’ for column

WBOY
WBOYOriginal
2016-06-07 17:20:371495browse

ERROR 1366 (HY000): Incorrect string value:rsquo;XXXrsquo; for column

环境

MySQL Server 5.5.27 + 命令行工具

问题

插入中文字符数据出现如下错误:

ERROR 1366 (HY000): Incorrect stringvalue: '\xBD\xF1\xCC\xEC\xCC\xEC...' for co

lumn 'MESSAGECONTENT' at row 1

环境再现

--以下是插入语句:  
insert into sms_inbox values('123456','123456', 'cd', sysdate(), '今天天 
气很好', 1, sysdate(), '123456'); 
  
--报错:  
ERROR 1366 (HY000): Incorrect stringvalue: '\xBD\xF1\xCC\xEC\xCC\xEC...' for co 
lumn 'MESSAGECONTENT' at row 1 
  
--解决:设置编码  
set names gbk; 
  
Query OK, 0 rows affected (0.02 sec) 

总结
当出现乱码,就是编码的问题,可以尝试设置数据库的编码(set nams gbk)。

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn