Tag Archives: MySQL FAQ

[Solved] MySQL: datetime (0) null default NULL

Resolve the MySQL: datetime (0) null default null error

Remove the database from mysql5 7 is exported as SQL in mysql5 When importing on 5, there will be an error of datetime (0) null default null. The main reason for the error is mysql5 7 and mysql5 Datetime and timestamp of 5 are incompatible, mysql5 7. The exported format is datetime (0) and mysql5 5, the syntax is not recognized

Solution:

1) Change datetime(0) to datetime, or timestamp(0) to timestamp in the export statement

2) Keep database version consistent

be careful

When datetime is set to CURRENT_TIMESTAMP by default, the length of CURRENT_TIMESTAMP cannot be specified as 0 as well.

datetime(0) NULL DEFAULT CURRENT_TIMESTAMP(0)

Correct grammar

datetime NULL DEFAULT CURRENT_TIMESTAMP