Causes
In the local database execution test platform database structure file Data_struct.sql, the execution of the build table statement resembles the following:
CREATE TABLE' demo ' (' ID ' )int(Ten) unsigned not NULLAuto_increment,' name ' Longtext COLLATE utf8_bin,' Create_time 'datetime not NULL DEFAULT Current_timestamp, ' Update_time 'datetime not NULL DEFAULT Current_timestamp, PRIMARY KEY(' id ')) ENGINE=InnoDB auto_increment= - DEFAULTCHARSET=UTF8 COLLATE=Utf8_bin;
The following errors were found during the process
1067 (42000defaultfor'create_time' )
After
After Google for reasons, and combined with their own situation, found the cause of the problem.
The reasons for netizens ' guesses are:
The Sql_mode settings in the 1.mysql configuration are not correct (the first reaction is this), check your configuration did not find the problem
Reason for the 2.mysql version (root cause of the problem)
Results
After seeing the version, I checked the version of MySQL and found that the test platform was version 5.7 and was using version 5.5. Using Current_timestamp as the default value for DateTime is only supported in versions after 5.6.
"Solutions"
Upgrade the local database version.
MySQL Set default value current_timestamp for a datetime type field, throwing Invalid default value for error