mysql数据导入时,出现了如下错误
[root@master ~]# mysql -u root -pStt@123456 -D 111 < DB/111.sql
ERROR 1067 (42000) at line 97: Invalid default value for 'api_call_time'
解决:
进入数据库输入如下命令:
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.00 sec)
将sql_mode的值复制出来
将其中NO_ZERO_IN_DATE,NO_ZERO_DATE这两个字段删除
之后进入mysql配置文件
vim my.cf
添加如下内容:
sql_mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
之后重启MySQL服务即可
执行
mysql -u root -pStt@123456 -D 111 < DB/111.sql
即可成功导入