1 mysql> show variables like '%time_zone%';
+------------------+--------+
| Variable_name | Value |
+------------------+--------+
| system_time_zone | EDT |
| time_zone | SYSTEM |
+------------------+--------+
2 rows in set (0.01 sec)
2 centos EDT 修改 成 CST
[root@had1 ~]# mv /etc/localtime /etc/localtime.bak
[root@had1 ~]# ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
[root@had1 ~]# date
Thu Jun 29 17:04:30 CST 2023
[root@had1 ~]# /sbin/hwclock -w
[root@had1 ~]# date -u
Thu Jun 29 09:04:51 UTC 2023
注意:要重起 mysql
mysql> SELECT @@global.system_time_zone,@@global.time_zone;
+---------------------------+--------------------+
| @@global.system_time_zone | @@global.time_zone |
+---------------------------+--------------------+
| CST | SYSTEM |
+---------------------------+--------------------+
1 row in set (0.00 sec)
3 mysql> show variables like '%time_zone%'
-> ;
+------------------+--------+
| Variable_name | Value |
+------------------+--------+
| system_time_zone | EDT |
| time_zone | +08:00 |
+------------------+--------+
2 rows in set (0.01 sec)
mysql> set time_zone='SYSTEM'