2

I changed my server time using this command

cp /usr/share/zoneinfo/US/central etc/localtime

Ever since I changed the server time. All my MySQL records have changed the timestamp fields 6 hours ahead. I tried changing the time back and the records won't update. Any ideas?

Web Server OS is CentOS

user7282
  • 5,106
  • 9
  • 41
  • 72
Rafael
  • 7,605
  • 13
  • 31
  • 46

2 Answers2

4

the timestamp didn't changed. The problem is that the database still with the old timezone (which by the time difference I suppose was UTC). The get values you expect you should change also your database timezone.

Here is better explained how to do that: How do I set the time zone of MySQL?

But basically you can change it forever (global), with this command:

SET GLOBAL time_zone = 'America/New_York'; 

Or for each session with this other:

SET time_zone = 'America/New_York';
Community
  • 1
  • 1
manuelmhtr
  • 326
  • 2
  • 5
1

The timestamp is a session variable in MySQL. It reflects the value returned by now(). For more info read: http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_time_zone

You can specify the default time zone in your MySQL my.cnf configuration file as:

default_time_zone=America/New_York

and restart your MySQL service as:

sudo service mysqld restart
sid1408
  • 404
  • 3
  • 10