Mysql error 1366-Incorrect integer value solution, 1366 incorrect
Because this database server stores many databases and all of them are small databases, it initially runs on a windows server. Some time ago, due to the need to adjust the server room, I made adjustments to the database migration and front-end applications on a quiet night, after the adjustment, the test application can be accessed normally, and then I leave.
When I first got to work on Monday, I received feedback: the following error was reported when an article was published on the website background:
Copy codeThe Code is as follows:
Insert into doc_main (title, typeid, uptime, intro, ifhot, imgurl1, doctype, fileurl1, shunxu, titleurl, qitype) values ('test', '13 ', '2014-5-30 ', 'test', '1', '', '0','', '123 ')
Cause analysis process:
At first, I thought it was a problem with the database file, but after comparing the old and new database files, I did not find any exceptions. I initially decided it should be a problem with the database application, so I copied the preceding SQL statement and executed it directly on the mysql server. The execution result was disappointing and the following error was reported:
Copy codeThe Code is as follows:
[SQL] insert into doc_main (title, typeid, uptime, intro, ifhot, imgurl1, doctype, fileurl1, shunxu, titleurl, qitype) values ('test', '13 ', '2014-5-30 ', 'test', '1', '', '0','', '123 ')
[Err] 1366-Incorrect integer value: ''for column 'shunxu 'at row 1
After viewing the data table, it is found that the shunxu field requires an integer, and the default value is null. change its default value to 0. Restart the mysql service and test OK.
Of course, you can refer to the article "MySQL 5 cannot create automatically added fields" in this blog and comment out SQL-mode to solve the above problem.
MYSQL error: Incorrect integer value
Tj is an integer type. Therefore, you cannot assign a value of '', which can be NULL or 0.
Insert into r_news (title, body, date, user, menu, language, tj, keyword, guestbook) values ('wegsdfgs ', 'gfsdfgsdgff', '2017-05-26 ', 'cscs ', '47', 'cn ','','','')
Statement:
Insert into r_news (title, body, date, user, menu, language, tj, keyword, guestbook) values ('wegsdfgs ', 'gfsdfgsdgff', '2017-05-26 ', 'cscs ', '47', 'cn', 0 ,'','')
MySql ERROR 1366 (HY000): Incorrect string value: how to solve the problem?
You also need to change the character set of the table,
Alter table tbname convert to charset gbk;