MySQL 修改时区

来自姬鸿昌的知识库
跳到导航 跳到搜索

1.确认当前时区

mysql> show variables like "%time_zone%";
+------------------+--------+
| Variable_name    | Value  |
+------------------+--------+
| system_time_zone |        |
| time_zone        | SYSTEM |
+------------------+--------+
2 rows in set, 1 warning (0.00 sec)

上面是修改前的


2. 停止 MySQL Server 服务

3.编辑 my.ini 配置文件

......
# Path to the database root
datadir=C:/ProgramData/MySQL/MySQL Server 5.7/Data

default-time_zone = '+8:00'
......

在 datadir 后面插入一行 "default-time_zone = '+8:00'"


4.启动 MySQL Server 服务

5.确认时区变更生效

mysql> show variables like "%time_zone%";
+------------------+--------+
| Variable_name    | Value  |
+------------------+--------+
| system_time_zone |        |
| time_zone        | +08:00 |
+------------------+--------+
2 rows in set, 1 warning (0.00 sec)