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

How to solve the problem that mysql timestamp cannot be inserted with default values

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Next, let's learn how to solve the problem that mysql timestamp cannot be inserted with default values. I believe everyone will benefit a lot after reading it. The text is not much in essence. I hope that how to solve the problem that mysql timestamp cannot be inserted with default values is what you want.

When you create a table, one field is of type timestamp, and the default value is' 1970-01-01 00-00-00-00-00-01-01-00, so it cannot be inserted.

Field timestamp NOT NULL DEFAULT '1970-01-01 0000VOULAR 01'

Solution:

Set the time_zone of mysql to the UTC time zone

Set global time_zone='+0:00'

After setting, select now (); differs from the current time by 8 hours

The default value of time_zone is system, that is, CST, East 8

The corresponding relationship of the time zone is:

UTC:time_zone='+0:00'

CST:time_zone='+8:00'

Under the time zone of East 8, set the default value

Timestamp NOT NULL DEFAULT '1970-01-01 08:00:01

It can also be successful.

After reading this article on how to solve the problem that mysql timestamp cannot be inserted with default values, many readers will certainly want to know more about it. For more industry information, you can follow our industry information section.

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: 255

*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