MySQL时区 [英] MySQL Time Zones

查看:82
本文介绍了MySQL时区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有详尽的MySQL时区列表?

Is there an exhaustive list of MySQL Time Zones?

似乎MySQL设置中time_zone的有效值取决于主机操作系统,但我无法找到可能值的列表.

It seems that the valid values for time_zone in MySQL settings are dependent on the host Operating System but I have been unable to find a list of possible values.

我需要时间显示卡尔加里当地时间.

I need the time to show Calgary local time.

推荐答案

来自 MySQL 5.7文档(重点是我的):

时区值可以多种格式给出,没有一种是 区分大小写:

timezone values can be given in several formats, none of which are case sensitive:

值"SYSTEM"表示时区应与时区相同 系统时区.

The value 'SYSTEM' indicates that the time zone should be the same as the system time zone.

该值可以以字符串形式给出,该字符串指示与UTC的偏移量,例如 为"+10:00"或"-6:00".

The value can be given as a string indicating an offset from UTC, such as '+10:00' or '-6:00'.

该值可以作为命名时区给出,例如 欧洲/赫尔辛基",美国/东部"或"MET". 命名时区可以是 仅当mysql数据库中的时区信息表时使用 已创建并填充.

The value can be given as a named time zone, such as 'Europe/Helsinki', 'US/Eastern', or 'MET'. Named time zones can be used only if the time zone information tables in the mysql database have been created and populated.

应注意,MySQL timezone 变量的默认设置是MySQL启动时的SYSTEM.从操作系统设置中获取SYSTEM值(例如,从符号链接/etc/localtime引用的文件中)

It should be noted that the MySQL timezone variable's default setting is SYSTEM at MySQL startup. The SYSTEM value is obtained from an operating system setting (e.g. from the file that is referenced by the symlink /etc/localtime)

MySQL的默认 timezone 变量可以在启动时通过提供以下命令行选项初始化为其他值:

MySQL's default timezone variable can be initialised to a different value at start-up by providing the following command line option:

--default-time-zone=timezone

或者,如果要在选项文件中提供值,则应使用以下语法来设置变量:

Alternatively, if you are supplying the value in an options file, you should use the following syntax to set the variable:

--default-time-zone='timezone'

如果您是MySQL SUPER用户,则可以使用以下语法在运行时从MYSQL>提示符处设置SYSTEM time_zone 变量:

If you are a MySQL SUPER user, you can set the SYSTEM time_zone variable at runtime from the MYSQL> prompt using the following syntax:

SET GLOBAL time_zone=timezone;

MySQL还支持单个SESSION timezone 值,这些值默认为GLOBAL time_zone 环境变量值.要在会话期间更改会话时区值,请使用以下语法:

MySQL also supports individual SESSION timezone values which defaults to the GLOBAL time_zone environment variable value. To change the session timezone value during a SESSION, use the following syntax:

SET time_zone=timezone;

为了询问现有的MYSQL 时区设置值,可以执行以下SQL来获取这些值:

In order to interrogate the existing MYSQL timezone setting values, you can execute the following SQL to obtain these values:

SELECT @@global.time_zone, @@session.time_zone;

对于它的价值,我简单地搜索了 mysql time_zone配置的有效值,并查看了第一个结果.

For what it's worth, I simply googled mysql time_zone configuration valid values and looked at the first result.

这篇关于MySQL时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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