美文网首页
Invalid default value for timest

Invalid default value for timest

作者: 即墨灯火 | 来源:发表于2017-09-23 22:34 被阅读13次

That is because of server SQL Mode - NO_ZERO_DATE.

From the reference:

NO_ZERO_DATE - In strict mode, don't allow '0000-00-00' as a valid date. You can still insert zero dates with the IGNORE option. When not in strict mode, the date is accepted but a warning is generated.

How to solve this if you still want a '0000-00-00' as default value?

  1. open file: /etc/mysql/mysql.conf.d/mysqld.cnf in an editor of your choice.

  2. Look for: sql_mode, it will be somewhere under [mysqld].

  3. and set sql_mode to the following:

NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
  1. Save and then restart mysql service by doing:

  2. sudo service mysql restart

Reference

Stack Overflow

相关文章

网友评论

      本文标题:Invalid default value for timest

      本文链接:https://www.haomeiwen.com/subject/eeshextx.html