2025年boot连接不上mysql数据库_关于springboot 连接mysql 数据库报错问题

boot连接不上mysql数据库_关于springboot 连接mysql 数据库报错问题springboot 连接 MySQL 运行报错 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 serverTimezo

springboot连接MySQL运行报错:

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.

这个问题: 原因是mysql 数据库安装的时候没有将时区选为中国时区 默认是人家美国的 所以出现这个问题 我的原因是我下载的数据库是解压版的 所以也没有更改时区

在这个问题上 网上有很多 我一共解决了几种方式:

mysql> show global variables like “time_zone”;

查看数据库时区 由于我的修改过了 没有修改过 value 这里显示system

set global variables time_zone ‘+08:00’ 这是时区

另外可以在修改mini.ini 文件 mysql 安装目录下

我这里叫my-default.ini这个文件 里面添加default-time-zone=’+08:00′ 修改设置

但是我这里不知道什么原因上面修改有时候好使 有时候又不好使了

那么我这里又除了上面两种操作外还在项目的jdbc连接上 设置了

spring.datasource.url = jdbc:mysql://localhost:3306/wdksaif?serverTimezone=UTC&characterEncoding=utf-8

最终不报错了。

编程小号
上一篇 2025-03-31 21:21
下一篇 2025-04-23 20:06

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/hz/142013.html