0

For my Django application, I had to set the time zone to UTC, however I am not able to set it as I couldn't find any tables related to time zone in the system database.

How do I get those? the scripts available in here https://dev.mysql.com/downloads/timezones.html only relates to loading of data in the tables and not creating them.

  • MySQL Version: 5.7
  • OS: Windows
1

For Windows installations, see this page in MySQL documentation: Time zone description tables, where it states:

This package contains time zone description tables which can be used with the MySQL server by users whose systems do not include zoneinfo files (e.g. Microsoft Windows, HP-UX).

1

I used to face the same issue as you and I resolved it by following these quick steps.

Please follow below:

Environment:

  • MySQL Version: 5.7

  • OS: Windows 10 (64 bit)

Steps:

  • Download the package that contains the data files of pre-built time zone tables. You can download here https://dev.mysql.com/downloads/timezones.html
    • timezone_2018e_posix_sql.zip - POSIX standard for MySQL version 5.7
  • Extract the downloaded package, you will then have a file named timezone_posix.sql
  • Open a command line in the root directory of MySQL. Ex: On my computer this is "C:\Program Files\MySQL\MySQL Server 5.7\bin"
  • Run the command mysql -u root -p to login to MySQL with root access and then enter password.
  • Run the command show databases; to view all database. You will see a database named mysql. You need to insert data into the mysql database
    • Run the command use mysql;
  • Finally, you can insert data by issuing the command source *path timezone_posix.sql*.

After inserting the timezone data, you can test by issuing the following query:

 SELECT CONVERT_TZ('2018-07-02 14:46:46','utc','America/Los_Angeles')

If the result is not null, you're successful!!!

0

mysql_tzinfo_to_sql — Load the Time Zone Tables : http://dev.mysql.com/doc/refman/5.7/en/mysql-tzinfo-to-sql.html this might help you

  • Thanks gongsun, however my OS is windows so the above doesn't hold true for me. – nishith83 Sep 13 '16 at 6:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.