Search code examples
mysqllinuxopensuse

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.

The box is OpenSuse 12.3, and the MySQL version is 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. 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.


Solution

  • 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.

    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.