MySQL 5.7 Invalid default value for ' Create_time ' error resolution

Source: Internet
Author: User

Source: http://blog.itpub.net/15498/viewspace-2136006/

Due to the upgrade of the database, today in the execution of SQL file from MySQL 5.6 times wrong:

Mysql> Source Cms_user.sql
Query OK, 0 rows Affected (0.00 sec)

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

ERROR 1067 (42000): Invalid default value for ' Create_time '
ERROR 1146 (42S02): Table ' ixinnuo_zxpt.cms_user ' doesn ' t exist


Since MySQL 5.6 timestamp set Default rule change, cannot be "0000 00-00 00:00:00"

Workaround:
View Sql_mode:
Mysql> 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.01 sec)

Modify Sql_mode, remove No_zero_in_date,no_zero_date:
Mysql> set 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.00 sec)

Re-execution, success:
Mysql> Source Cms_user.sql
Query OK, 0 rows Affected (0.00 sec)

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

Query OK, 0 rows affected (0.55 sec)

Query OK, 1 row affected (0.07 sec)

MySQL 5.7 Invalid default value for ' Create_time ' error resolution

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.