现象:
MySQL导入数据库时报错:ERROR 1292 (22007): Incorrect datetime value: ‘0000-00-00 00:00:00’ for column ‘return_create_time’ at row 1
原因:
时间字段的格式为 ‘0000-00-00 00:00:00’,不能使用 no_zero_date 模式,通过show variables like 'sql_mode';命令查看
mysql> show 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_ENGINE_SUBSTITUTION | ±--------------±----------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.01 sec)
解决办法:
去掉NO_ZERO_DATE
临时解决方案:
mysql> set global sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
永久解决方案:
添加到my.cnf里边
sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';