MySQL mysql_tzinfo_to_sql program

后端 未结 6 832
抹茶落季
抹茶落季 2021-01-05 15:10

I am using MySQL 5.0.51b on microsoft windows xp. I am trying to load data from zoneinfo files(generated by library downloaded from here) to database tables as described her

相关标签:
6条回答
  • 2021-01-05 15:28

    The command "mysql_tzinfo_to_sql" doesn't work on Windows. You have to download the timezone packages wich contains SQL statements and populate the timezone tables using the "source" command, like this:

    mysql> use mysql ;
    mysql> source /path/to/file/timezone_posix.sql ;
    

    Check the following links for reference:

    Blog: https://discourse.looker.com/t/cannot-connect-time-zone-tables-dont-appear-to-be-loaded-in-mysql/208/6

    Scripts sql: http://downloads.mysql.com/general/timezone_2016a_posix_sql.zip , http://downloads.mysql.com/general/timezone_2016a_leaps_sql.zip

    0 讨论(0)
  • 2021-01-05 15:31
    mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -uadmin -ppassword mysql
    
    0 讨论(0)
  • 2021-01-05 15:33

    None of the 'populate file' methods worked for me with mysql 8.

    A lot of answer contains this link: http://dev.mysql.com/downloads/timezones.html There's downloadable zip files that contain sql files. Putting it to any directory didn't help. One thing helped me: I issued a "use mysql;" and executed the content of the downloadable sql file as a script.

    0 讨论(0)
  • 2021-01-05 15:38

    based on Francisco Corrales Morales answer.

    For MySQL 5.7+ on Windows 10 machine, my procedure is

    1. download latest POSIX Standard time zone script under 5.7+ section from https://dev.mysql.com/downloads/timezones.html
    2. Extract the file then there would be a single SQL file named timezone_posix.sql
    3. run the sql script, in my case, use command line below
    bin\mysql.exe --host=localhost --port=3306 --user=USERNAME -p mysql < c:\...\Downloads\timezone_2020d_posix_sql\timezone_posix.sql
    

    Note make sure you run the time zone script under mysql database/schema.

    0 讨论(0)
  • 2021-01-05 15:42

    You don't need to run mysql_tzinfo_to_sql on Windows.

    For Windows just do this:

    1. Download the files. Links here
    2. Move them to your MySQL directory. Example: C:\ProgramData\MySQL\MySQL Server 5.5\data\mysql
    3. Restart your server.
    4. Now, if you want, you can change your timezone like this: SET time_zone = 'America/Costa_Rica';
    5. Check it with SELECT NOW();

    More information here: MySQL

    And take a look at this: Answer

    0 讨论(0)
  • 2021-01-05 15:44

    For Windows, MySQL supplies an already loaded database for you to download and stick in your data directory: http://dev.mysql.com/downloads/timezones.html

    Copied from the user comments on the MySQl docs:

    Posted by Jyotsna Channagiri on November 20 2008 6:28pm

    Hi,

    I thought this information will helps somebody who are looking for changing mysql timezone.

    The steps are:

    1. Download the timezone table structure and data from http://dev.mysql.com/downloads/timezones.html

    2. Copy and paste the data in your Mysql/data/mysql folder

    3. Restart your mysql server.

    4. mysql> SET GLOBAL time_zone = 'America/Toronto';

    5. mysql> SET SESSION time_zone = 'America/Toronto';

    6. Check SELECT @ @global.time_zone , @ @session.time_zone ; It should give you the time zone you set just before.

    Comment:

    Yes, but the tables provided by MySQL are outdated (generated by 2006p version of D olson's timezone library). I need the latest timezones data, hence i downloaded the latest library and generated the binaries. Now i need a way to load these tables in mysql.But i don't know how to do it on windows.

    Ah, I see. Then you're going to need to do one of two things. 1) get the tool that does this and compile it (or whatever) on Windows. If you're lucky, it's a perl script.

    2) fill the database on linux, then copy it to Windows. [This guy][http://it-idiot.einsamsoldat.net/2008/01/moving-mysql-database-from-windows-to-linux-redhat/comment-page-1/2] says it can be done, at least for MyIsam.

    0 讨论(0)
提交回复
热议问题