mysql_tzinfo_to_sql is a utility that is used to load time zones on systems that have a zoneinfo database to load the time zone tables (time_zone, time_zone_leap_second, time_zone_name, time_zone_transition and time_zone_transition_type) into the mysql database.

Most Linux, Mac OS X, FreeBSD and Solaris systems will have a zoneinfo database - Windows does not. The database is commonly found in the /usr/share/zoneinfo directory, or, on Solaris, the /usr/share/lib/zoneinfo directory.


mysql_tzinfo_to_sql can be called in several ways. The output is usually passed straight to the mysql client for direct loading in the mysql database.

shell> mysql_tzinfo_to_sql timezone_dir
shell> mysql_tzinfo_to_sql timezone_file timezone_name
shell> mysql_tzinfo_to_sql --leap timezone_file


Most commonly, the whole directory is passed:

shell>mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql

Load a single time zone file, timezone_file, corresponding to the time zone called timezone_name.

shell> mysql_tzinfo_to_sql timezone_file timezone_name | mysql -u root mysql

A separate command for each time zone and time zone file the server needs is required.

To account for leap seconds, use:

shell> mysql_tzinfo_to_sql --leap timezone_file | mysql -u root mysql

After populating the time zone tables, you should usually restart the server so that the new time zone data is correctly loaded.


Comments loading...