mysql5.7.21导入5.6的数据报Error

MysqL的数据从5.6导入到5.7时,若时间的认值为零会报错Error : Invalid default value for ‘comment_date’。

产生这个报错的原因:

NO_ZERO_DATE:在非严格模式下,可以插入形如“2014-07-17 23:29:00”的非法日期,MysqL数据库仅抛出一个警告。而启用该选项后,MysqL数据库不允许插入零日期,插入零日期会抛出错误而非警告。

解决方法如下:

MysqL -u root -p //登陆MysqL

Enter password:

Welcome to the MysqL monitor. Commands end with ; or g.

Your MysqL connection id is 26

Server version: 5.7.21 Homebrew

copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered Trademark of Oracle Corporation and/or its

affiliates. Other names may be Trademarks of their respective

owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

MysqL> set global sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'

-> ;

Query OK, 0 rows affected, 1 warning (0.01 sec)

MysqL> commit;

Query OK, 0 rows affected (0.00 sec)

MysqL> exit;

重新创建数据库,导入数据即可。

相关文章

MySQL 死锁 是指两个或多个事务互相等待对方持有的锁,从而导...
在MySQL中,InnoDB引擎通过Next-Key Locking技术来解决幻读问...
在数据库事务管理中,Undo Log 和 Redo Log 是两种关键日志,...
case when概述 sql语句中的case语句与高级语言中的switch语句...
其实很简单,只是为了忘记,做个记录,用的时候方便。 不管是...
1.进入服务,找到mysql服务,在属性里找到mysql的安装路径 2...