Home > Database > Mysql Tutorial > MySQL的ERROR1366(HY000):Incorrectstringvalue错误解决_MySQL

MySQL的ERROR1366(HY000):Incorrectstringvalue错误解决_MySQL

WBOY
Release: 2016-06-01 13:00:03
Original
1901 people have browsed it

错误描述:

MySQL [portaldb]> INSERT INTO prod_product VALUES (5,’ATS’,’1’,’最终事物一致’,”,’最终事物一致’,’1’,’1’,NULL,’http://130.51.23.246:20881/ipaas/ats/manage/create‘,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
ERROR 1366 (HY000): Incorrect string value: ‘\x80\xE7\xBB\x88\xE4\xBA…’ for column ‘PROD_NAME’ at row 1
MySQL [portaldb]>

可先阅读:
SQLyog v11.24查询MySQL5.6.24中文乱码的解决方法

其实还是字符集的问题。MySQL安装后设置为gbk,而我建表的时候用的是utf8。

<code class="language-shell hljs autohotkey">MySQL [portaldb]> show create table prod_product;

| prod_product | CREATE TABLE `prod_product` (
  `PROD_ID` smallint(6) NOT NULL AUTO_INCREMENT,
  `PROD_EN_SIMP` varchar(20) COLLATE utf8_bin NOT NULL DEFAULT &#39;&#39;,
  `PROD_TYPE` varchar(2) COLLATE utf8_bin NOT NULL,
  `PROD_NAME` varchar(60) COLLATE utf8_bin NOT NULL,
  `PROD_LOGOPIC_ID` varchar(10) COLLATE utf8_bin NOT NULL,
  `PROD_DESC` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT &#39;&#39;,
  `PROD_VALID_FLAG` varchar(2) COLLATE utf8_bin NOT NULL DEFAULT &#39;1&#39;,
  `PROD_SALE_FLAG` varchar(2) COLLATE utf8_bin NOT NULL DEFAULT &#39;1&#39;,
  `PROD_PARAM` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `PROD_OPEN_RESTFULL` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT &#39;&#39;,
  `PROD_START_RESTFULL` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `PROD_STOP_RESTFULL` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `PROD_MDYPWD_RESTFULL` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `PROD_FULLCLEAR_RESTFULL` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `PROD_KEYCLEAR_RESTFULL` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `PROD_SELTEDKEY_RESTFULL` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `PROD_CANCLE_RESTFULL` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `PROD_USED_AMOUNT_RESTFULL` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  PRIMARY KEY (`PROD_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8 COLLATE=utf8_bin |</code>
Copy after login

尝试把表改建为utf8的,插入也只是减少了错误(原来插入26条有20条报错,改了之后有5条报错),但是并没有根治。

最后,还是需要在数据库服务端设置字符集为utf8,问题解决。

总结:<br> 想对中文支持,还是全部统一用utf8好。虽然用gbk可能也是可以,但是毕竟现在整个开发包括javaee都是以utf8为标准了。

2015.6.25

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template