出错原因:

因为安装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. Html 标签初知

    Html 标签初知 什么是Html 标签 超文本标记语言(外国语简称:HTML)标记标签通常被称为HTML标签,HTML标签是HTML语言中最基本的单位,HTML标签是HTML(标准通用标记语言下的一 ...

  2. day03变量的命名规范,常量,输出:自带换行,输入,注释,数据类型,运算符,常用字符大小关系

    复习 ''' 1.语言的分类 -- 机器语言:直接编写0,1指令,直接能被硬件执行 -- 汇编语言:编写助记符(与指令的对应关系),找到对应的指令直接交给硬件执行 -- 高级语言:编写人能识别的字符, ...

  3. 【Python61--异常处理】

    一.URLrror 当我们的urlopen无法处理一个响应的时候就会出现一个urlerror的错误,但同时url会伴随一个res的属性,包含一个由错误编码和错误信息url 举例: import url ...

  4. PSR4规范

    定义类名规则: 完全限定类名必须有一个顶级命名空间(Vendor Name): 完全限定类名可以有多个子命名空间: 完全限定类名应该有一个终止类名: 下划线在完全限定类名中是没有特殊含义的: 字母在完 ...

  5. 智能合约 helloworld

    windows 平台 所以直接使用Remix在线编译环境 新建hello.sol文件 编辑如下 Remix 右边侧栏 setting 选择合适的编译器版本 这里选择 0.4.19 文件中输入如下内容  ...

  6. C/C++.判断文件是否存在(_access)

    1. int _access(char* path,int mode)头文件<io.h>功能:确定文件或文件夹的访问权限.如果指定的存取方式有效,则函数返回0,否则函数返回-1. 参数pa ...

  7. 第 8 章 容器网络 - 063 - 如何使用 Weave 网络?

    如何使用 Weave 网络? weave 是 Weaveworks 开发的容器网络解决方案. weave 创建的虚拟网络可以将部署在多个主机上的容器连接起来. 对容器来说,weave 就像一个巨大的以 ...

  8. javaScript_Demo 全选和反选单选框

    进行单选的全选和反选 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> &l ...

  9. pandas的数据结构之series

    Pandas的数据结构 1.Series Series是一种类似于一维数组的对象,由下面两个部分组成: index:相关的数据索引标签 values:一组数据(ndarray类型) series的创建 ...

  10. PAT 1069 The Black Hole of Numbers

    1069 The Black Hole of Numbers (20 分)   For any 4-digit integer except the ones with all the digits ...