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 should the MySQL time zone be set

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

The following mainly brings you how to set the MySQL time zone. I hope these words can bring you practical use, which is also the main purpose of this article that I edit how to set the MySQL time zone. All right, don't talk too much nonsense, let's just read the following.

The MySQL time zone defaults to the time zone of the CVM. It is often encountered in use. You can view the time zone SQL code with the following command

. Mysql > show variables like'% time_zone%';. +-+. | Variable_name | Value |. +-+. | system_time_zone | CST |. | time_zone | SYSTEM |. +-+. 2 rows in set (0.00 sec)

Note: if the value of time_zone is SYSTEM, its time zone is the same as that of the operating system.

You can modify the my.cnf

Add under [mysqld]

Default-time-zone=timezone

To change the time zone. Such as:

Default-time-zone ='+ 8VR 00'

Remember to restart msyql if you change it.

Be sure to add it under [mysqld], otherwise there will be an error message of unknown variable 'default-time-zone=+8:00'.

Alternatively, you can use the command set time_zone = timezone

For example, Beijing time (GMT+0800)

Set time_zone ='+ 8VR 00'

> in PHP programs > >

Date_default_timezone_set ('PRC') or die (' time zone setting failed, please contact the administrator!')

> > in the query or use of the database > >

/ / once the database is connected, it is followed by the code to change the MySQL time.

Mysql_query ("SET time_zone ='+ 8or die 00'") or die ("time zone setting failed, please contact the administrator!")

For the above about how the MySQL time zone should be set, do you find it very helpful? If you need to know more, please continue to follow our industry information. I'm sure you'll like it.

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