Get the App
SLTechnology News&Howtos  ›  Database  › 

The solution to the error of creating Table Times in MySQL Database

Shulou Source: shulou.com Published: 2022-06-01 17:39:51 09月20日 Update

How to solve the error when creating tables in MySQL database: Invalid default value for 'create_date'? I believe that many novice rookies can do nothing about this. Through the summary of this article, I hope you can find a solution.

Scene

[Err] 1067-Invalid default value for 'create_date', for creating a table type is as follows:

`create_ date`timestamp (0) NOT NULL ON UPDATE CURRENT_TIMESTAMP (0) COMMENT 'creation time'

Solve

MySQL5.6.44 and MySQL5.7.27timestamp default value rule change, cannot be "0000 00-0000: 00:00"

Solution:

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 to 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"

After reading this article, can you solve the problem of creating tables in MySQL database independently? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel. Thank you for reading.

Tags: Data databases methods Times more articles helpless content scenarios this skills beginners time industry rules sentences information information channels questions channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Apple Shulou Information Microsoft Shulou Technology