add primary key and it said invalid default value for datetime code example

Example: Invalid default value for 'post_date' ignore this error

if you generated the script from the MySQL workbench.

	The following line is generated
    
    SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
    Remove TRADITIONAL from the SQL_MODE, and then the script should work fine

Else, you could set the SQL_MODE as Allow Invalid Dates
	
    SET SQL_MODE='ALLOW_INVALID_DATES';
    
reference :
https://stackoverflow.com/questions/9192027/invalid-default-value-for-create-date-timestamp-field

Tags:

Misc Example