Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report