Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load MySQL timezone tables

Tags:

mysql

centos

trying to load the MySQL timezone tables, read many related posts here and the MySQL docs and can't find solution my problem. I connect SSH via PUTTY as root and issue this command:

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

I get these errors:

Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.

Any idea how to resolve?

like image 425
TransitDataHead Avatar asked May 20 '16 21:05

TransitDataHead


People also ask

How do I get MySQL time zone?

To explicitly specify the system time zone for MySQL Server at startup, set the TZ environment variable before you start mysqld. If you start the server using mysqld_safe, its --timezone option provides another way to set the system time zone. The permissible values for TZ and --timezone are system dependent.

Does MySQL store timezone?

MySQL converts TIMESTAMP values from the current time zone to UTC for storage, and back from UTC to the current time zone for retrieval. (This does not occur for other types such as DATETIME .) By default, the current time zone for each connection is the server's time.

What is Mysql_tzinfo_to_sql?

The mysql_tzinfo_to_sql program loads the time zone tables in the mysql database. It is used on systems that have a zoneinfo database (the set of files describing time zones). Examples of such systems are Linux, FreeBSD, Solaris, and macOS.

Is MySQL time UTC?

UTC_TIMESTAMP() function in MySQL is used to check current Coordinated Universal Time (UTC) date and time value. It returns the current UTC date and time value in YYYY-MM-DD HH:MM:SS or YYYYMMDDHHMMSS. uuu format, depending on whether the function is used in string or numeric context.


1 Answers

Those aren't errors. They're warnings, and you can disregard them. Your time zone tables should be populated, despite these warnings.


The utility being used in the question is a script bundled with MySQL Server called mysql_tzinfo_to_sql. It reads your Linux (or FreeBSD, Solaris, or macOS) system's time zone database and creates SQL statements from the information it discovers, that will load the time zone tables in MySQL.

The warnings are about time zones the utility found on the system that it doesn't recognize as containing usable time zone info.

The documentation also mentions a pre-built file you can use, with the caveat that using this may mean that some time zones may not be an exact match for those on your system... so if you are doing time zone conversions both inside of MySQL and out, there could be inconsistencies, since time zones do occasionally change.

like image 65
Michael - sqlbot Avatar answered Oct 04 '22 03:10

Michael - sqlbot