出错原因:

因为安装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的更多相关文章

  1. 连接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 ...

  2. 解决MySQL报错The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents .....

    1.前言 今天在用SpringBoot2.0+MyBatis+MySQL搭建项目开发环境的时候启动项目发现报了一个很奇怪的错,报错内容如下: java.sql.SQLException: The se ...

  3. 连接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为美国时间:如下图: ...

  4. MySQL报错The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents

    参考资料:https://blog.csdn.net/qq_37630354/article/details/82814330 在property里加上最后这个参数即可

  5. 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 ...

  6. SpringBoot------连接MySQL报错:The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized

    报错提示: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zon ...

  7. 解决报错:The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized

    Cannot create PoolableConnectionFactory (The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized . ...

  8. 关于springboot 连接mysql 数据库报错问题

    springboot连接MySQL运行报错: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more ...

  9. 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 ...

随机推荐

  1. 用ab的post方式进行测试

    一.Ab是常用的性能测试工具,因为它支持windows…… 通常使用的命令是ab –c –n –k -r,分别表示:模拟终端数.发送包数.请求是否带keepalive.忽略错误,默认都是以GET方式去 ...

  2. TCP之种种连接异常

    1. connect出错: (1) 若TCP客户端没有收到syn分节的响应,则返回ETIMEOUT错误:调用connect函数时,内核发送一个syn,若无响应则等待6s后再发送一个,若仍然无响应则等待 ...

  3. ipan笔记

    // 对于mysql来说, 如果字段没有设置其 default值, 则会自动 设置 default值为null.同理没有设置not null, 则会自动允许null =yes // create ta ...

  4. 再谈git和github-深入理解-2

    github中的 sloc是什么意思? sloc: source lines of code: 代码行数, 源代码行. 要向仓库中 create file/upload file/edit file等 ...

  5. 【做题】SDOI2017硬币游戏——方程&概念处理

    原文链接 https://www.cnblogs.com/cly-none/p/9825339.html 题意:给出\(n\)个长度为\(m\)的互不相同的01串.有另一个串,初始为空.不断进行如下操 ...

  6. 论文笔记: Mutual Learning to Adapt for Joint Human Parsing and Pose Estimation

    Mutual Learning to Adapt for Joint Human Parsing and Pose Estimation 2018-11-03 09:58:58 Paper: http ...

  7. Bytom Java版本离线签名

    比原项目仓库: Github地址:https://github.com/Bytom/bytom Gitee地址:https://gitee.com/BytomBlockchain/bytom tx_s ...

  8. vivado 创建PL工程

    参考来源 https://china.xilinx.com/video/hardware/i-and-o-planning-overview.html 前言 我Win10系统上的Xilinx Plat ...

  9. HashMap 和 HashTable差别

    代码版本 JDK每一版本都在改进.本文讨论的HashMap和HashTable基于JDK 1.7.0_67.源码见这里 1. 时间 HashTable产生于JDK 1.1,而HashMap产生于JDK ...

  10. mysql 常用sql语句

    权限 撤销权限revoke all on *.* from 'root'@'192.168.0.197' ; 撤销权限revoke all on *.* from 'xx_db' @'%'; 给指定用 ...