mysql_tzinfo_to_sql 程序会在 mysql 数据库中加载时区表。它用于具有 zoneinfo 数据库(描述时区的文件集合)的系统。此类系统的示例有 Linux、FreeBSD、Solaris 和 macOS。这些文件的一个可能位置是 /usr/share/zoneinfo 目录(Solaris 上为 /usr/share/lib/zoneinfo)。如果您的系统没有 zoneinfo 数据库,可以使用在 第 7.1.15 节,“MySQL 服务器时区支持” 中描述的可下载包。The mysql_tzinfo_to_sql program loads the
time zone tables in the mysql database. It is
used on systems that have a
zoneinfo database (the set
of files describing time zones). Examples of such systems are
Linux, FreeBSD, Solaris, and macOS. One likely location for
these files is the /usr/share/zoneinfo
directory (/usr/share/lib/zoneinfo on
Solaris). If your system does not have a zoneinfo database, you
can use the downloadable package described in
Section 7.1.15, “MySQL Server Time Zone Support”.
mysql_tzinfo_to_sql 可以通过多种方式调用:mysql_tzinfo_to_sql can be invoked several ways:
mysql_tzinfo_to_sqltz_dirmysql_tzinfo_to_sqltz_file tz_namemysql_tzinfo_to_sql --leaptz_file
对于第一次调用语法,将 zoneinfo 目录路径名传递给 mysql_tzinfo_to_sql 并将输出发送到 mysql 程序。例如:For the first invocation syntax, pass the zoneinfo directory path name to mysql_tzinfo_to_sql and send the output into the mysql program. For example:
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql
mysql_tzinfo_to_sql 读取系统的时区文件并从中生成 SQL 语句。mysql 处理这些语句以加载时区表。mysql_tzinfo_to_sql reads your system's time zone files and generates SQL statements from them. mysql processes those statements to load the time zone tables.
第二种语法使 mysql_tzinfo_to_sql 仅加载与时区名 tz_name 对应的单个时区文件 tz_file:The second syntax causes mysql_tzinfo_to_sql
to load a single time zone file
tz_file that corresponds to a time
zone name tz_name:
mysql_tzinfo_to_sqltz_filetz_name| mysql -u root mysql
如果您的时区需要考虑闰秒,请使用第三种语法调用 mysql_tzinfo_to_sql,它会初始化闰秒信息。tz_file 是您的时区文件名称:If your time zone needs to account for leap seconds, invoke
mysql_tzinfo_to_sql using the third syntax,
which initializes the leap second information.
tz_file is the name of your time zone
file:
mysql_tzinfo_to_sql --leap tz_file | mysql -u root mysql
在运行 mysql_tzinfo_to_sql 后,最好重启服务器,以便它不再使用之前缓存的任何时区数据。After running mysql_tzinfo_to_sql, it is best to restart the server so that it does not continue to use any previously cached time zone data.