Home  >  Article  >  Database  >  Mysql method to view and modify time zone

Mysql method to view and modify time zone

藏色散人
藏色散人forward
2020-04-25 13:58:252960browse

Mysql method to view and modify time zone

Method 1

#查看时区
show variables like "%time_zone%";
set global time_zone = '+8:00'; ##修改mysql全局时区为北京时间,即我们所在的东8区
set time_zone = '+8:00'; ##修改当前会话时区
flush privileges; #立即生效

Method 2

## linux

# vim /etc/my.cnf ##在[mysqld]区域中加上
default-time_zone = '+8:00'
# /etc/init.d/mysqld restart ##重启mysql使新时区生效

windowsModify the configuration file my.ini

Path

C:\ProgramData\MySQL\MySQL Server 5.7

ProgramData is a hidden folder

Add under [mysqld]

#设置默认时区
default-time-zone='+08:00'

Restart mysql in cmd as administrator

net stop mysql
net start mysql

If an error is reported

服务名无效。 请键入 NET HELPMSG 2185 以获得更多的帮助。

is an error in the service name. Please check the service name in the service

windows r, open the run, enter services.msc, and find the mysql service.

Check the service name mysql57,

net stop mysql57
net start mysql57

Mysql method to view and modify time zone

Recommended: "

mysql video tutorial"

The above is the detailed content of Mysql method to view and modify time zone. For more information, please follow other related articles on the PHP Chinese website!

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