[Solved]: Incorrect datetime value: ‘0000-00-00 00:00:00’ for column

Problem faced: Incorrect datetime value: ‘0000-00-00 00:00:00’ for column.

Solution: The best way to do this is to export the MySQL dump file using below command from the database.

mysqldump -uroot -ppasswordname databasename > database_name.sql

Now, you have `database_name.sql` and try to open the file and search the string `0000-00-00 00:00:00` and replace it with `CURRENT_TIMESTAMP`. You can do that with below command:

sed -i.bu 's/'\''0000-00-00 00:00:00'\''/CURRENT_TIMESTAMP/g' database_name.sql

Once in your file when you replaced all `0000-00-00 00:00:00` with `CURRENT_TIMESTAMP`. You can import that into new separate MySQL 5.7 installed separately successfully.

However, there are different suggestion at stackoverflow. You can go through this if you need.

That’t it. You can test that and let me know if anything.



Leave a Reply

Your email address will not be published. Required fields are marked *