Posted By: Anonymous
When I tried to alter the table it showed the error:
ERROR 1067 (42000): Invalid default value for 'created_at'
I googled for this error but all I found was as if they tried to alter the timestamp so it occurred. However here I am trying to add a new column and I am getting this error:
mysql> ALTER TABLE investments ADD bank TEXT; ERROR 1067 (42000): Invalid default value for 'created_at'
and my table’s last two columns are
Here is my table structure:
The problem is because of sql_modes.
Please check your current sql_modes by command:
show variables like 'sql_mode' ;
And remove the sql_mode “NO_ZERO_IN_DATE,NO_ZERO_DATE” to make it work.
This is the default sql_mode in mysql new versions.
You can set sql_mode globally as root by command:
set global sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';