JDBC driver连接MySQL运行报错The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than
出错原因:
因为安装mysql的时候时区设置的不正确。 mysql默认的是美国的时区,而我们中国大陆要比他们迟8小时,采用GMT+8:00格式。
也就是说是数据库和系统时区差异所造成的。
验证:运行cmd登录mysql,控制台输入:
show variables like '%time_zone%';
如果显示SYSTEM则是时区有问题,有两个解决方法:
解决方法一:
在jdbc连接的url后面加上serverTimezone=GMT即可解决问题,如果需要使用gmt+8时区,需要写成GMT%2B8。
1.1
按照网上的教程,我第一次是在数据库后面加上(没有引号):"?serverTimezone=GMT+8"
报错:java.sql.SQLException: No timezone mapping entry for 'GMT 8' ;
1.2
后来又查到,需要将+改成%2B,"?serverTimezone=GMT%2B8"就可以了:
1.3
有大神提到:如果把数据库时区改了,那么插入数据库的时间都会自动减8小时。(暂时还没有用到)
解决方案:比如是SpringBoot2.0,在jdbc配置上加了一个&serverTimezone=UTC就行了。
解决方法二:
修改MySQL的配置文件,MySQL配置文件是my.ini文件在你的安装目录下去找,我的是C:\web\mysql-8.0.13\my.ini
用记事本打开,在[mysqld]节点后面加上这句话:
default-time-zone='+08:00'
再次运行:
show variables like '%time_zone%';
显示+8:00就成功了:
此时不用在写?serverTimezone=GMT%2B8都可以运行成功。
JDBC driver连接MySQL运行报错The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than的更多相关文章
- 连接mysql报错 : The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone...
time zone 时区错误 DBEAVER连接MySQL运行报错The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or repres ...
- 解决MySQL报错The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents .....
1.前言 今天在用SpringBoot2.0+MyBatis+MySQL搭建项目开发环境的时候启动项目发现报了一个很奇怪的错,报错内容如下: java.sql.SQLException: The se ...
- 连接MySQL报错The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone.
MySQL time zone 时区错误 使用root用户登陆执行命令: ---> show variables like '%time_zone%'; 默认值system为美国时间:如下图: ...
- MySQL报错The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents
参考资料:https://blog.csdn.net/qq_37630354/article/details/82814330 在property里加上最后这个参数即可
- com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone. 问题解决方法
一.问题 今天用mybatis连接数据库时出现了如下错误: com.mysql.cj.exceptions.InvalidConnectionAttributeException: The serve ...
- SpringBoot------连接MySQL报错:The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized
报错提示: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zon ...
- 解决报错:The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized
Cannot create PoolableConnectionFactory (The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized . ...
- 关于springboot 连接mysql 数据库报错问题
springboot连接MySQL运行报错: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more ...
- SpringBoot报错:The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone
解决方法: 在数据库连接url配置后边加&serverTimezone=GMT%2B8 例: jdbc:mysql://127.0.0.1:3306/test改为jdbc:mysql://12 ...
随机推荐
- shell批量修改mysql用户密码
需求 现在有这么一个需求, 需要大批量修改用户的密码, 需要注意的规则是: 必须添加的字符: *$#sjdKw% 用户名的第一位+*$#sjdKw%+用户名的最后一位,比如用户名chenglee,密码 ...
- 安卓内嵌H5只展示部分静态页面
问题: 安卓内嵌H5在华为P9部分机型只展示h5静态页面无法展示接口返回渲染的页面 解决办法: Android 关闭硬件加速 android:hardwareAccelerated=" ...
- Android studio新建文件出现setContentView(R.layout.activity_main);中的R标红错误解决方法
今天打开Android studio突然出现了setContentView(R.layout.activity_main);中的R标红错误,这已经不是第一次出现这个错误了,真心的觉得Android s ...
- 使用SpotBugs/FindBugs进行代码检查
原po:https://blog.csdn.net/zhangb00/article/details/8407070 SpotBugs 介绍 SpotBugs是Findbugs的继任者(Findbug ...
- angular-cli.json配置参数解释,以及依稀常用命令的通用关键参数解释
一. angular-cli.json常见配置 { "project": { "name": "ng-admin", //项目名称 &quo ...
- mysql常用的查询优化
原文链接:https://www.jb51.net/article/39221.htm 1.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引. 2 ...
- _map_char_stats
可以控制玩家进入地图后进行属性平衡. `comment` 备注 `map` 地图ID `vip`vip等级 `shengming`生命 `liliang` 力量 `minjie` 敏捷 `zhili` ...
- wrk 安装使用
==================== 安装 ====================https://github.com/wg/wrk/wiki sudo yum -y groupinstall ...
- nodejs web API 相关杂项
场景是这样的: docker-compose中起多个服务,其中有一个是nodejs写的作为web API. 这个API 的使用者有2类: 1 docker-compose网络内其他特定服务访问,作为C ...
- angular面试记忆的内容
1.ng-class的用法:ng-class="{red:true}"; 2.ng-repeat怎么可以添加重复数据.ng-repeat="item in arr tra ...