Home >Database >Mysql Tutorial >How to modify the default time zone of mysql

How to modify the default time zone of mysql

王林
王林forward
2020-07-11 17:47:383532browse

How to modify the default time zone of mysql

1. View MySQL current time zone and time

(Recommended tutorial: mysql tutorial)

show variables like "%time_zone%";  #查看时区

How to modify the default time zone of mysql

#time_zone indicates that mysql uses the system's time zone, system_time_zone indicates that the system uses the CST time zone

select curtime();  #查看时间
select now();  #查看日期+时间

2. Modify the time zone

You can modify the time zone by modifying the my.cnf configuration file

# vim /etc/my.cnf

Add the following content in the [mysqld] area:

default-time_zone = '+8:00'

After the modification is completed, you need to restart MySQL for the configuration to take effect.

The above is the detailed content of How to modify the default time zone of mysql. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete