gpt4 book ai didi

mysql - 无法永久设置 UTC 时区

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:19:37 26 4
gpt4 key购买 nike

我正在使用这个 time-zone-support用于在我的机器上设置 UTC 时区,但问题是我无法永久设置它,当我重新启动 MySQL 服务器时它会更改为系统时间。

盒子是OpenSuse 12.3,MySQL版本是5.5.33

mysql> SET time_zone = UTC;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT @@global.time_zone, @@session.time_zone;
+--------------------+---------------------+
| @@global.time_zone | @@session.time_zone |
+--------------------+---------------------+
| UTC | UTC |
+--------------------+---------------------+
1 row in set (0.00 sec)

现在,当我重新启动 mysql 服务器时,它会恢复到系统状态。重启服务器后:

mysql> SELECT @@global.time_zone, @@session.time_zone;
+--------------------+---------------------+
| @@global.time_zone | @@session.time_zone |
+--------------------+---------------------+
| SYSTEM | SYSTEM |
+--------------------+---------------------+
1 row in set (0.00 sec)

我也尝试过使用默认时区,但它给我错误。

mysql> default-time-zone=UTC;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'default-time-zone=UTC' at line 1
mysql>

谁能告诉我我在这里遗漏了什么,以及如何永久设置 UTC 时区。

最佳答案

我正在回答我自己的问题,因为在寻找答案的过程中我找到了解决方案 here

我正在编辑 my.cnf 文件并在文件末尾输入 default-time-zone = UTC,就像我在 Windows 机器上所做的那样,它不是在 Linux/Opensuse 中工作。

然后我在my.cnf的[mysqld]部分输入了default-time-zone = UTC,新的时区就被拾取了,现在UTC 时区设置永久

关于mysql - 无法永久设置 UTC 时区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24220019/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com