Get the App
SLTechnology News&Howtos  ›  Database  › 

How should the MySQL time zone be set

Shulou Source: shulou.com Published: 2022-06-01 19:45:31 09月10日 Update

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.

Tags: Time zone available through following code content commands data database time administrator management contact operating system actually that is regular meetings nonsense text more server Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia macOS MySQL Xiaomi Shulou Information