Home >Database >Mysql Tutorial >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
C:\ProgramData\MySQL\MySQL Server 5.7
#设置默认时区 default-time-zone='+08:00'Restart mysql in cmd as administrator
net stop mysql net start mysqlIf 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.
net stop mysql57 net start mysql57Recommended: "
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!