【问题标题】:OpenSuse - Setting the timezone on mysqlOpenSuse - 在 mysql 上设置时区
【发布时间】:2014-06-12 11:48:41
【问题描述】:

我正在关注'MySQL Server Time Zone Support' 在 myqlon OpenSuse 虚拟机上设置默认时区。 我已经阅读了一些关于此的其他问题,但似乎我遗漏了一些东西。

我可以在我的机器上看到区域信息:

linux-gn77:~ # ls -l /usr/share/zoneinfo/
total 280
drwxr-xr-x  2 root root  4096 May  4 10:35 Africa
drwxr-xr-x  6 root root  4096 May  4 10:35 America
drwxr-xr-x  2 root root  4096 May  4 10:35 Antarctica
drwxr-xr-x  2 root root  4096 May  4 10:35 Arctic
drwxr-xr-x  2 root root  4096 May  4 10:35 Asia
drwxr-xr-x  2 root root  4096 May  4 10:35 Atlantic
drwxr-xr-x  2 root root  4096 May  4 10:35 Australia
drwxr-xr-x  2 root root  4096 May  4 10:35 Brazil
-rw-r--r--  2 root root  2102 Oct 28  2013 CET
-rw-r--r--  2 root root  2294 Oct 28  2013 CST6CDT
drwxr-xr-x  2 root root  4096 May  4 10:35 Canada
drwxr-xr-x  2 root root  4096 May  4 10:35 Chile
-rw-r--r--  4 root root  2411 Oct 28  2013 Cuba
-rw-r--r-- 13 root root   118 Oct 28  2013 UTC
-rw-r--r-- 13 root root   118 Oct 28  2013 Universal
-rw-r--r--  4 root root  1464 Oct 28  2013 W-SU
-rw-r--r--  2 root root  1873 Oct 28  2013 WET
-rw-r--r-- 13 root root   118 Oct 28  2013 Zulu

现在我尝试通过发出以下命令来加载时区:

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

我收到以下错误:

ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysql_tzinfo_to_sql: command not found' at line 1

当我检查mysql的版本时,它如下:

mysql> SHOW VARIABLES LIKE "%version%";


+-------------------------+------------------+
| Variable_name           | Value            |
+-------------------------+------------------+
| innodb_version          | 5.5.33           |
| protocol_version        | 10               |
| slave_type_conversions  |                  |
| version                 | 5.5.33           |
| version_comment         | openSUSE package |
| version_compile_machine | i686             |
| version_compile_os      | Linux            |
+-------------------------+------------------+

有人可以建议我如何设置时区吗?

【问题讨论】:

    标签: mysql linux database opensuse


    【解决方案1】:

    我已经找到了这个问题的问题。

    基本上脚本mysql_tzinfo_to_sql不在系统中,是 mysql-community-server-tools,所以首先我们要安装mysql_tzinfo_to_sql。

    zypper install mysql-community-server-tools
    

    这会将脚本 mysql_tzinfo_to_sql 放在 /usr/bin/ 文件夹中。

    现在您可以使用以下命令加载时区信息:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-21
      • 2013-06-29
      • 2011-07-19
      • 2016-03-29
      • 2017-12-09
      • 1970-01-01
      • 2013-06-15
      • 2012-08-31
      相关资源
      最近更新 更多