您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

一文搞定Mysql时区错误问题

2025/12/2 0:09:46发布48次查看
本篇文章给大家带来了关于mysql的相关知识,在mysql启动时会检查当前系统的时区并根据系统时区设置全局参数system_time_zone的值,下面主要给大家介绍了关于如何永久摆脱mysql时区错误问题(idea数据库可视化插件配置),希望对大家有帮助。
推荐学习:mysql视频教程
今天在做项目的时候遇到一个关于mysql时区的问题,在这里汇总记录一下解决过程,希望可以帮助到有需要的人。
问题描述在做项目的时候突然遇到以下的报错,可以看到是说 数据库的时区错误,这里使用的是mysql 8.0.15数据库。
这里试用了idea提供的数据库可视化插件。
以下报错使得无法访问数据库。
org.apache.ibatis.exceptions.persistenceexception: ### error querying database. cause: java.sql.sqlexception: 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.### the error may exist in studentmapper.xml### the error may involve ll.getall### the error occurred while executing a query### cause: java.sql.sqlexception: 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.
原因分析这里首先考虑是数据库本身的默认时区设置的问题,
其次考虑在设置idea数据库可视化插件连接的时候的时区的设置问题
解决方案:通过以下步骤解决了此问题:
打开命令窗口,进入mysql服务:
接着查询时区:
show variables like "%time_zone%";
这里显示system表示跟随系统,一般情况下是没有问题的,但是偶尔也会出现问题,这里我们就直接更改成'+8:00'
set global time_zone='+08:00';
注意:这只是临时修改,重启mysql服务后就会失效
下面介绍永久修改:
永久的修改:修改mysql的配置文件my.ini,添加:default-time-zone=’+08:00’,重启mysql生效,注意一定要在 [mysqld] 之下加 ,否则会出现 unknown variable ‘default-time-zone=+8:00’
接下来再去idea里面测试一下。
发现结果还是报错,那么据考虑是idea数据库可视化插件的链接配置问题。
接下来修改idea数据库可视化插件配置:
在这里加上时区’+8:00’,进行测试。完美解决。
推荐学习:mysql视频教程
以上就是一文搞定mysql时区错误问题的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product