W3cubDocs

/MariaDB

mysql_tzinfo_to_sql

mysql_tzinfo_to_sql is a utility 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.

From MariaDB 10.4.6, mariadb-tzinfo-to-sql is a symlink to mysql_tzinfo_to_sql.

Usage

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

Examples

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.

Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.

© 2019 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.
https://mariadb.com/kb/en/mysql_tzinfo_to_sql/