v2r.jpg

mysql> show GLOBAL VARIABLES like '%sql_mode%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| sql_mode      |       |
+---------------+-------+
1 row in set

解决方法:
  方式一:先执行select @@sql_mode,复制查询出来的值并将其中的NO_ZERO_DATE删除,然后执行set sql_mode = '修改后的值'。 此方法只在当前会话中生效

  方式二:先执行select @@global.sql_mode,复制查询出来的值并将其中的NO_ZERO_DATE删除,然后执行set global sql_mode = '修改后的值'。 此方法在当前服务中生效,重新MySQL服务后失效

  方法三:在mysql的安装目录下,打开my.ini或my.cnf文件,新增 sql_mode = ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION, 重启mysql,法永久生效
http://stackoverflow.com/questions/32037353/error-1067-for-default-of-timestamp-column-where-there-is-no-default

As of MySQL 5.6.5, TIMESTAMP and DATETIME columns can be automatically initializated and updated to the current date and time (that is, the current timestamp). Before 5.6.5, this is true only for TIMESTAMP, and for at most one TIMESTAMP column per table. The following notes first describe automatic initialization and updating for MySQL 5.6.5 and up, then the differences for versions preceding 5.6.5.

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code