Home  >  Article  >  Database  >  Mysql错误1366

Mysql错误1366

WBOY
WBOYOriginal
2016-06-01 13:05:491221browse

由于这个数据库服务器存放的数据库比较多且都是小数据库,所以最初的时候是运行在windows服务器上的。前一段时间由于机房服务器要做调整,于是我便在一个夜深人静的夜晚对数据库进行的迁移及前台应用程序进行了调整,调整结束后测试应用均可以正常访问后我便离去了。

周一刚上班就收到反馈:网站后台发布文章报如下错误:

代码如下:


insert into doc_main (title,typeid,uptime,intro,ifhot,imgurl1,doctype,fileurl1,shunxu,titleurl,qitype) values('test','13','2011-5-30','test','1','','0','','','','279')

原因分析过程:

    起初我以为是数据库文件出现了问题,但是比对新老数据库文件后,没有发现异常,初步判断应该是数据库应用程序的问题,于是我便把上面的这句SQL语句复制后直接在mysql服务器上执行,执行的结果是令人失望的,报了如下错误:

代码如下:


[SQL] insert into doc_main (title,typeid,uptime,intro,ifhot,imgurl1,doctype,fileurl1,shunxu,titleurl,qitype) values('test','13','2011-5-30','test','1','','0','','','','279')

[Err] 1366 - Incorrect integer value: '' for column 'shunxu' at row 1

查看数据表后发现shunxu这个字段要求是整数,而默认是null,把它的默认值改为0。重启mysql服务后,测试OK。

当然你也可以参照本博客中的《MySQL 5不能创建自动增加的字段》文章,注释掉sql-mode也可解决上述问题。

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