mysql> show variables like '%time_zone%';
+------------------+--------+
| Variable_name | Value |
+------------------+--------+
| system_time_zone | UTC |
| time_zone | SYSTEM |
+------------------+--------+
2 rows in set (0.85 sec)
设置全局
set global time_zone='+8:00';
设置当前会话
set time_zone='+8:00';
立即生效
flush privileges;
再次查看
mysql> show variables like '%time_zone%';
+------------------+--------+
| Variable_name | Value |
+------------------+--------+
| system_time_zone | UTC |
| time_zone | +08:00 |
+------------------+--------+
2 rows in set (0.01 sec)
查看操作系统时区
timedatectl
UTC是协调世界时(Universal Time Coordinated)
GMT(Greenwich Mean Time)是格林尼治平时
而CST却同时可以代表如下 4 个不同的时区:
美国中部时间:Central Standard Time (USA) UT-6:00
澳大利亚中部时间:Central Standard Time (Australia) UT+9:30
中国标准时间:China Standard Time UT+8:00
古巴标准时间:Cuba Standard Time UT-4:00