如何使用xampp在ubuntu中的mysql数据库中填充区域表 [英] How to populate zone tables in mysql database within ubuntu with xampp

查看:73
本文介绍了如何使用xampp在ubuntu中的mysql数据库中填充区域表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试根据此文档导入时区: http://dev.mysql.com/doc/refman/5.7/en/mysql-tzinfo-to-sql.html .

I am trying to import time zones according to this document: http://dev.mysql.com/doc/refman/5.7/en/mysql-tzinfo-to-sql.html.

当我尝试通过终端即打第一个命令时

When I try hitting even first command through terminal i.e.

mysql_tzinfo_to_sql tz_dir

它说

There were fatal errors during processing of zoneinfo directory 'tz_dir'

当我跑步时:

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

然后返回

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

操作系统: Ubuntu

服务器:XAMPP(具有mariadb)

Server: XAMPP (having mariadb)

因此,我无法将时区数据导入到mysql数据库的区域表中.

So, I am not able to import timezone data into the zone tables of mysql database.

推荐答案

今天早晨,当我尝试在生产服务器(使用CentOS)上填充时区表时,也遇到了这个问题.

I also had this issue this morning while trying to populate the timezone tables on our production server (using CentOS).

我通过从开发计算机中导出表创建脚本来解决此问题(在Windows上填充表只需要下载表并将它们复制到正确的目录中).

I worked around this problem by exporting the table creation script from my development computer (populating the tables on Windows simply requires to download the tables and copy them in the proper directory).

我稍微调整了创建脚本,它现在对我有用:

I tweaked the creation script a little bit and it is now working for me:

由于脚本太长,我无法将其发布在答案中.

I cannot post it in my answers since the script is too long.

https://drive.google.com/file/d/0B7iwL5F-hwr_YkItRXk2Z1VZdlE/view?usp = sharing

这是带有注释的版本(但似乎不起作用,因此请使用无注释的版本).

Here's a version with the comment (but it doesn't seems to work, so use the version without comments).

https://drive.google.com/file/d/0B7iwL5F-hwr_dWdjTDREcXNHQmM/view?usp = sharing

该脚本的运行时间不应超过几秒钟.您可能需要使用root用户才能运行它.

The script should take no more than a few second to run. You'll probably need to use the root user to be able to run it.

您可以使用此查询来验证安装:

You can use this query in order to validate the installation:

SELECT CONVERT_TZ(CURRENT_DATE(),'UTC','America/Montreal');

如果返回NULL而不是datetime,则表示脚本失败.

If it returns NULL instead of a datetime, it means the script failed.

成功

这篇关于如何使用xampp在ubuntu中的mysql数据库中填充区域表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆