Invalid default value for timestamp field in MySQL 5.7

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 timestamp field in MySQL 5.7)