简体   繁体   English

无法永久设置UTC时区

[英]Unable to set the UTC timezone permamently

I am using this time-zone-support for setting the UTC timezone on my machine, But the trouble is that I am not able to set it permanently, it changes to System time when I restart the MySQL server. 我正在使用此时区支持在我的计算机上设置UTC时区,但是问题是我无法永久设置它,当我重新启动MySQL服务器时,它更改为系统时间。

The box is OpenSuse 12.3, and the MySQL version is 5.5.33 该框是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)

now when I restart the mysql server, it reverts back to system. 现在,当我重新启动mysql服务器时,它将恢复为系统状态。 After restarting the server: 重新启动服务器后:

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

I have tried doing the default time zone as well, but its giving me error. 我也尝试过使用默认时区,但是它给了我错误。

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> 

Can someone please let me know what am I missing here, and how to set the UTC timezone permanently. 有人可以让我知道我在这里想念什么,以及如何永久设置UTC时区。

I am answering my own question, as in the pursuit of the answer I have found the solution here 我正在回答自己的问题,正如在寻求答案时,我在这里找到了解决方案

I was editing my.cnf file and entering default-time-zone = UTC at the end of the file, as I did in windows machine, it does NOT work in Linux/Opensuse. 我编辑my.cnf文件并输入default-time-zone = UTC在文件的结尾,就像我在Windows机器一样,它不会在Linux的/ openSUSE的工作。

Then I entered default-time-zone = UTC in the [mysqld] section of the my.cnf, and the new time zone is picked up, and now the UTC timezone is set permanently . 然后,在my.cnf的[mysqld]部分中输入default-time-zone = UTC ,并选择新的时区,现在将UTC时区永久设置为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM