mysql错误总结-ERROR 1067 (42000): Invalid default value for TIMESTAMP

1. ERROR 1067 (42000): Invalid default value for 'FAILD_TIME'   (对TIMESTAMP  类型的子段如果不设置缺省值或没有标志not null时候在创建表时会报这个错误)
这是因为sql_mode中的NO_ZEROR_DATE导制的,在strict mode中不允许'0000-00-00'作为合法日期

使用下面的命令查看sql_mode

mysql>show variables like 'sql_mode';

+---------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| Variable_name | Value                                                                                                                                     |
+---------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| sql_mode      | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+---------------+-------------------------------------------------------------------------------------------------------------------------------------------+

将上面的NO_ZERO_DATE改为下面的 ALLOW_INVALID_DATES

mysql> set sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,ALLOW_INVALID_DATES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';

上面的设置是临时设置,在重新登陆后,该设置又恢复为NO_ZERO_DATE

posted @ 2017-03-11 18:54  拜占廷船长  阅读(19663)  评论(0编辑  收藏  举报