====== Change timezone on Ubuntu server ======
I have a virtual machine somewhere, where i host a web application. I had to change the time zone since the time stamps in MySql were wrong. Here is how to do it without installing a GUI:First, start the TUI time management tool
su@www:~$ sudo dpkg-reconfigure tzdata
[sudo] password for su:
no talloc stackframe at ../source3/param/loadparm.c:4864, leaking memory
You will be presented with the following screen. Simply select the region and city and you’re done with this step.
[{{ :linux:ubuntu:timezone1.png?600 |Select region}}]
[{{ :linux:ubuntu:timezone2.png?600 |Select city}}]
Current default time zone: 'Europe/Zagreb'
Local time is now: Wed Apr 15 09:50:03 CEST 2015.
Universal Time is now: Wed Apr 15 07:50:03 UTC 2015.
su@www:~$
Now you can sync the clock with a NTP server, and check if the date is OK.
su@www:~$ sudo ntpdate zg1.ntp.carnet.hr
15 Apr 10:00:24 ntpdate[46331]: step time server 161.53.123.5 offset 27.628667 sec
su@www:~$ date
Wed Apr 15 10:00:27 CEST 2015
su@www:~$
Now, the only thing I had to do was to restart my MySql server – which was set to use system time zone as its time zone. You can check which time zone is set in MySql by selecting @@global.time_zone.
su@www:~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 109732
Server version: 5.5.41-0ubuntu0.14.04.1 (Ubuntu)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> SELECT @@global.time_zone, @@session.time_zone;
+--------------------+---------------------+
| @@global.time_zone | @@session.time_zone |
+--------------------+---------------------+
| SYSTEM | SYSTEM |
+--------------------+---------------------+
1 row in set (0.02 sec)
mysql>
You can also leave the system time zone as is, and change the MySql time zone to something different than SYSTEM by using any of these:
SET GLOBAL time_zone = '+1:00';
SET GLOBAL time_zone = 'Europe/Zagreb';
SET @@global.time_zone='+02:00';