您好,登錄后才能下訂單哦!
場景
????????????[Err] 1067 - Invalid default value for 'create_date',對于創建表種的語句如下:
??????????`create_date`?timestamp(0)?NOT?NULL?ON?UPDATE?CURRENT_TIMESTAMP(0)?COMMENT?'創建時間'
解決
MySQL5.6.44以及MySQL5.7.27timestamp設定默認值規則改變,不能為”0000 00-00 00:00:00”
解決方法:
查看sql_mode:
mysql> show session 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 |
+---------------+-------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)
修改sql_mode,去掉NO_ZERO_IN_DATE,NO_ZERO_DATE:
mysql> set sql_mode="ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION";
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。