Spec-Zone .ru
спецификации, руководства, описания, API
|
As mentioned earlier, when the time zone rules change, applications that use the old rules become out of date. To stay current, it is necessary to make sure that your system uses current time zone information is used. For MySQL, there are two factors to consider in staying current:
The operating system time affects the value that the MySQL server uses for times if
its time zone is set to SYSTEM
. Make sure that your operating system is
using the latest time zone information. For most operating systems, the latest update or service pack
prepares your system for the time changes. Check the Web site for your operating system vendor for an
update that addresses the time changes.
If you replace the system's /etc/localtime
timezone
file with a version that uses rules differing from those in effect at mysqld startup, you should restart mysqld so that it uses the updated rules. Otherwise,
mysqld might not notice when the system changes its
time.
If you use named time zones with MySQL, make sure that the time zone tables in the
mysql
database are up to date. If your system has its own zoneinfo
database, you should reload the MySQL time zone tables whenever the zoneinfo database is updated, using
the instructions given earlier in this section. For systems that do not have their own zoneinfo
database, check the MySQL Developer Zone for updates. When a new update is available, download it and
use it to replace your current time zone tables. mysqld caches time zone information that it looks
up, so after replacing the time zone tables, you should restart mysqld to make sure that it does not continue to
serve outdated time zone data.
If you are uncertain whether named time zones are available, for use either as the server's time zone setting or by clients that set their own time zone, check whether your time zone tables are empty. The following query determines whether the table that contains time zone names has any rows:
mysql> SELECT COUNT(*) FROM
mysql.time_zone_name;
+----------+| COUNT(*) |+----------+| 0 |+----------+
A count of zero indicates that the table is empty. In this case, no one can be using named time zones, and you don't need to update the tables. A count greater than zero indicates that the table is not empty and that its contents are available to be used for named time zone support. In this case, you should be sure to reload your time zone tables so that anyone who uses named time zones will get correct query results.
To check whether your MySQL installation is updated properly for a change in Daylight Saving Time rules, use a test like the one following. The example uses values that are appropriate for the 2007 DST 1-hour change that occurs in the United States on March 11 at 2 a.m.
The test uses these two queries:
SELECT CONVERT_TZ('2007-03-11 2:00:00','US/Eastern','US/Central');SELECT CONVERT_TZ('2007-03-11 3:00:00','US/Eastern','US/Central');
The two time values indicate the times at which the DST change occurs, and the use of named time zones requires that the time zone tables be used. The desired result is that both queries return the same result (the input time, converted to the equivalent value in the 'US/Central' time zone).
Before updating the time zone tables, you would see an incorrect result like this:
mysql>SELECT CONVERT_TZ('2007-03-11 2:00:00','US/Eastern','US/Central');
+------------------------------------------------------------+| CONVERT_TZ('2007-03-11 2:00:00','US/Eastern','US/Central') |+------------------------------------------------------------+| 2007-03-11 01:00:00 |+------------------------------------------------------------+mysql>SELECT CONVERT_TZ('2007-03-11 3:00:00','US/Eastern','US/Central');
+------------------------------------------------------------+| CONVERT_TZ('2007-03-11 3:00:00','US/Eastern','US/Central') |+------------------------------------------------------------+| 2007-03-11 02:00:00 |+------------------------------------------------------------+
After updating the tables, you should see the correct result:
mysql>SELECT CONVERT_TZ('2007-03-11 2:00:00','US/Eastern','US/Central');
+------------------------------------------------------------+| CONVERT_TZ('2007-03-11 2:00:00','US/Eastern','US/Central') |+------------------------------------------------------------+| 2007-03-11 01:00:00 |+------------------------------------------------------------+mysql>SELECT CONVERT_TZ('2007-03-11 3:00:00','US/Eastern','US/Central');
+------------------------------------------------------------+| CONVERT_TZ('2007-03-11 3:00:00','US/Eastern','US/Central') |+------------------------------------------------------------+| 2007-03-11 01:00:00 |+------------------------------------------------------------+