MySQL DST Patch / Update

To update the MySQL server,  you really do not have to run a patch.  That is a common question I was getting from people was where to get the patch.  You actually have to patch the OS and then from there run a command on MySQL.  If you’re OS doesn’t use zoneinfo, there is even a fix for this without having to reinstall a newer version of MySQL.

Taken from http://dev.mysql.com/doc/refman/5.0/en/time-zone-support.html:

If your system has its own zoneinfo database (the set of files describing time zones), you should use the mysql_tzinfo_to_sql program for filling the time zone tables. Examples of such systems are Linux, FreeBSD, Sun Solaris, and Mac OS X. One likely location for these files is the /usr/share/zoneinfo directory. If your system does not have a zoneinfo database, you can use the downloadable package described later in this section.

The mysql_tzinfo_to_sql program is used to load the time zone tables. On the command line, pass the zoneinfo directory pathname to mysql_tzinfo_to_sql and send the output into the mysql program. For example:

shell&gt; <strong class="userinput">mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql</strong>   

mysql_tzinfo_to_sql reads your system’s time zone files and generates SQL statements from them. mysql processes those statements to load the time zone tables.

mysql_tzinfo_to_sql also can be used to load a single time zone file or to generate leap second information:

  • To load a single time zone file tz_file that corresponds to a time zone name tz_name, invoke mysql_tzinfo_to_sql like this:

    shell&gt; <strong class="userinput">mysql_tzinfo_to_sql <em class="replaceable">tz_file</em> <em class="replaceable">tz_name</em> | mysql -u root mysql</strong> 

    With this approach, you must must execute a separate command to load the time zone file for each named zone that the server needs to know about.

  • If your time zone needs to account for leap seconds, initialize the leap second information like this, where tz_file is the name of your time zone file:

    shell&gt; <strong class="userinput">mysql_tzinfo_to_sql --leap <em class="replaceable">tz_file</em> | mysql -u root mysql</strong> 

If your system is one that has no zoneinfo database (for example, Windows or HP-UX), you can use the package of pre-built time zone tables that is available for download at the MySQL Developer Zone:

<a target="_top" href="http://dev.mysql.com/downloads/timezones.html">http://dev.mysql.com/downloads/timezones.html</a>   

This time zone package contains .frm, .MYD, and .MYI files for the MyISAM time zone tables. These tables should be part of the mysql database, so you should place the files in the mysql subdirectory of your MySQL server’s data directory. The server should be stopped while you do this and restarted afterward.

Warning: Do not use the downloadable package if your system has a zoneinfo database. Use the mysql_tzinfo_to_sql utility instead. Otherwise, you may cause a difference in datetime handling between MySQL and other applications on your system.

  1. Thanks for such informative article

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>