I have a table with 2M records and everything works fine until few hours ago.
suddenly it throw error on a query that previously works fine for more than 1 year.
The problem is that inserting a correct dateTime like 2019-07-15 22:22:47
into a timestamp column return error:
Incorrect datetime value: ‘0000-00-00 00:00:00’ for column ‘created_at’ at row 1
1- I did duplicated table structure and query works fine on duplicated table
2- I did run yum update
today.
3- OS: CentOS release 6.10 (Final)
4- MySql: Server version: 8.0.16 MySQL Community Server – GPL
Edit:
i have read other questions but its completely different, I’ve posted the answer
2
Answers
I found it, posting as answer that may help others
It seems that latest mysql update have some new roles added for comparing datetime values, however i think the error thrown is completely irrelevant. i had a trigger on my table which check some parameter and also check if created_at column is equal to '0000-00-00 00:00:00' then change it to current_timestamp. part of trigger is
it just a simple compare and the result should be true or false, and should not throw the zero date exception.
however i removed this part and everything is up now
sql-mode = “”
Save this file
systemctl restart mysqld
example:
UPDATE TABLE test SET modified =’0000-00-00 00:00:00′