MySQL:[Err] 1292 - Incorrect datetime value: '0000-00-00 00:00:00' for column 'CREATE_TIME' at row 1

problem


When importing data navicat, given:
[Err] 1292 - Incorrect datetime value: '0000-00-00 00:00:00' for column 'CREATE_TIME' at row 1

Here Insert Picture Description


the reason

This is because the current MySQL does not support datetime 0. situation.


solve

Modify sql_mode:

sql_mode: SQL Mode defines the MySQL should support the SQL syntax, data validation, etc. This makes it easier to use MySQL in different environments.


Global sql_mode

View Global sql_mode:

select @@global.sql_mode;

We can see, O_ZERO_DATE, the NO_ZERO_IN_DATE , these two settings removed.

Here Insert Picture Description

Modify global sql_mode:

set @@global.sql_mode = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';

Here Insert Picture Description

Current sql_mode

View current sql_mode:

select @@sql_mode;

Here Insert Picture DescriptionModify the current sql_mode:

set @@sql_mode = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';

Here Insert Picture Description

OK, problem solved.

Here Insert Picture Description


While the above may also solve our problems, but once the restart MySQL, you must reset the time and the current global sql_mode.

Modify the configuration sql_mode

Sql_mode modify configuration MySQL configuration file mysql.ini in, you do not have to re-set each restart MySQL sql_mode up.

  • Close MySQL
net stop MySQL57
  • MySQL configuration modifications
    in the my.ini [mysqld] was added under:
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
  • Start MySQL
net start MySQL57


END!



reference:

[1]: https: //my.oschina.net/shadowolf/blog/3005188
[2]: https: //www.cnblogs.com/mmyy-blog/p/9626326.html
[3]: MySQL affairs, lock , SQLMode, partition

Published 136 original articles · won praise 36 · views 30000 +

Guess you like

Origin blog.csdn.net/sinat_40770656/article/details/101198274