欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 运维知识 > 数据库 >内容正文

数据库

MySQL 数据库时区设置方法,“The server time zone value ‘�й���׼ʱ��‘ is unrecognized or represents ...” 问题解决

发布时间:2025/4/16 数据库 59 豆豆
生活随笔 收集整理的这篇文章主要介绍了 MySQL 数据库时区设置方法,“The server time zone value ‘�й���׼ʱ��‘ is unrecognized or represents ...” 问题解决 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

连接 mysql 数据库时提示如下异常,是时区问题导致的。

An error occurred while establishing the connection:Long Message: The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the 'serverTimezone' configuration property) to use a more specifc time zone value if you want to utilize time zone support.Details:Type: java.sql.SQLExceptionSQL State: 01S00

报错翻译:
服务器时区值 ‘�й���׼ʱ��’ 无法识别或表示多个时区。如果您想利用时区支持,您必须配置服务器或 JDBC 驱动程序(通过 ‘serverTimezone’ 配置属性)来使用更具体的时区值。

解决方法:
修改 my.ini 文件,加入时区设置 default-time_zone='+8:00' 即可,重启 mysql 服务生效。

不重启 mysql 服务临时生效可以这样设置
set global time_zone='+8:00';
flush privileges;

喜欢的点个赞❤吧!

总结

以上是生活随笔为你收集整理的MySQL 数据库时区设置方法,“The server time zone value ‘�й���׼ʱ��‘ is unrecognized or represents ...” 问题解决的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。