mysql insert 有一个时间字段,'0000-00-00 00:00:00'格式为这样。插入 报错
ERROR 1292 (22007): Incorrect datetime value: '0000-00-00 00:00:00' for column 'return_create_time' at row 1
mysql允许将’0000-00-00’保存为“伪日期”,如果不使用no_zero_date sql模式。
root@localhost :(none)03:38:46>show variables like 'sql_mode';
+---------------+------------------------------------------------------------------------------------------------------------------------------------+
| variable_name | value |
+---------------+------------------------------------------------------------------------------------------------------------------------------------+
| sql_mode | 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)
参数中含有: no_zero_date
解决办法: 去掉 no_zero_date
set global sql_mode='strict_trans_tables,no_zero_in_date,error_for_division_by_zero,no_auto_create_user,no_engine_substitution';
(注意,上面语句为一行)
如果不生效修改配置文件重新启动数据库。