SQLSTATE [HY000]:常规错误:1298未知或不正确的时区:'UTC'窗口 [英] SQLSTATE[HY000]: General error: 1298 Unknown or incorrect time zone: 'UTC' windows
问题描述
在Windows Wamp服务器中设置PHP源代码时出现此错误.
I am getting this error while setting up a PHP source code in Windows Wamp server.
SQLSTATE [HY000]:常规错误:1298未知或不正确的时区:'UTC'
SQLSTATE[HY000]: General error: 1298 Unknown or incorrect time zone: 'UTC'
请让我知道如何解决.
谢谢.
推荐答案
您可以通过三种方式解决此问题.
You have three ways to solve this problem.
安装时区数据库
Install the timezone database
mysql_tzinfo_to_sql 程序将时区表加载到mysql数据库中.它用于具有zoneinfo数据库(描述时区的文件集)的系统上.此类系统的示例是Linux,FreeBSD,Solaris和OSX.这些文件的一个可能位置是/usr/share/zoneinfo目录(在Solaris上为/usr/share/lib/zoneinfo).如果您的系统没有zoneinfo数据库,则可以使用第11.6节"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 OS X. 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 11.6, "MySQL Server Time Zone Support".
mysql_tzinfo_to_sql 可以通过几种方式调用:
mysql_tzinfo_to_sql can be invoked several ways:
shell> mysql_tzinfo_to_sql tz_dir
shell> mysql_tzinfo_to_sql tz_file tz_name
shell> mysql_tzinfo_to_sql --leap tz_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:
shell> 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:
shell> mysql_tzinfo_to_sql tz_file tz_name | mysql -u root mysql
如果您的时区需要考虑leap秒,请使用第三种语法调用 mysql_tzinfo_to_sql ,这将初始化the秒信息. 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:
shell> 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.
源: https://dev .mysql.com/doc/refman/5.7/en/mysql-tzinfo-to-sql.html
更新my.cnf文件以使用时区偏移量
Update your my.cnf file to use a timezone offset instead
default-time-zone = +0:00
从my.cnf文件中删除或注释违规语句
Remove or comment out offending statement from your my.cnf file
# default-time-zone = UTC
这将导致它从操作系统继承时区.
This will cause it to inherit the timezone from the OS instead.
这篇关于SQLSTATE [HY000]:常规错误:1298未知或不正确的时区:'UTC'窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!