ERROR 1067 (42000): Invalid default value for 'created_at'

前端 未结 14 1682
-上瘾入骨i
-上瘾入骨i 2020-12-04 07:31

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

14条回答
  •  粉色の甜心
    2020-12-04 08:20

    For Mysql5.7, login in mysql command line and run the command,

    mysql> show variables like 'sql_mode' ;
    

    It will show that NO_ZERO_IN_DATE,NO_ZERO_DATE in sql_mode.

    Try to add a line below [mysqld] in your mysql conf file to remove the two option, mine(mysql 5.7 on Ubuntu 16) is /etc/mysql/mysql.conf.d/mysqld.cnf

    Now restart mysql. It works!

提交回复
热议问题