MySQL Time Zone on OS X Mavericks

Setting up the time zone table on your MySQL instance on OS X shouldn’t be this hard, but it is. Normally, you do this with the following simple command and you’re done, but not on OS X.

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

The first problem you’ll encounter is that mysql_tzinfo_to_sql is not accessible from the command line. You either have to walk the path to its location and prepend the command with a dot or you have to reference the full path before the command (sans the dot).

The second problem you’ll encounter is that there are multiple errors in the time zone files, which will prevent the data from loading. I found a few options for dealing with this, but the easiest — by far — was to tell MySQL to force-load the files that worked and skip those that didn’t.

Here is the working command on my Mac.

/usr/local/mysql/bin/mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p --force mysql

Tom Rouillard

Leave a Reply

Your email address will not be published. Required fields are marked *