1

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.

Ben
  • 51,770
  • 36
  • 127
  • 149
Harbir
  • 453
  • 1
  • 7
  • 24
  • You cant set it in my.cnf http://stackoverflow.com/questions/19023978/should-mysql-have-its-timezone-set-to-utc – Mihai Jun 14 '14 at 12:43
  • @Mihai I have added the following in the my.cnf file,default_time_zone='+00:00' restarted the mysql server and still time is the SYSTEM time :( is there a chance that my.cnf file is not getting read? – Harbir Jun 14 '14 at 12:54
  • Try this answer http://stackoverflow.com/a/930914/1745672 – Mihai Jun 14 '14 at 13:09
  • @Mihai thanks, I am wondering what will be the alternative of "$ sudo dpkg-reconfigure tzdata" in openSuse? – Harbir Jun 15 '14 at 14:29
  • Sorry,Linux is not my thing. – Mihai Jun 15 '14 at 14:46
  • @Mihai, thank you for your efforts, I have found the solution below... – Harbir Jun 15 '14 at 22:47

1 Answers1

3

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.

Community
  • 1
  • 1
Harbir
  • 453
  • 1
  • 7
  • 24