[08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.
使用idea连接数据库的时候,报错为
[08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.

后来查阅资料发现这都是因为安装mysql的时候时区设置的不正确 mysql默认的是美国的时区,而我们中国大陆要比他们迟8小时,采用+8:00格式。使用的数据库是MySQL,在你没有指定MySQL驱动版本的情况下它自动依赖的驱动是8.0.12很高的版本,这是由于数据库和系统时区差异所造成的,在jdbc连接的url后面加上serverTimezone=GMT即可解决问题,如果需要使用gmt+8时区,需要写成GMT%2B8,否则会被解析为空。再一个解决办法就是使用低版本的MySQL jdbc驱动,5.1.28不会存在时区的问题。

在连接字符串后面加上?serverTimezone=UTC
其中UTC是统一标准世界时间。
完整的连接字符串示例:jdbc:mysql://localhost:3306/test?serverTimezone=UTC
或者还有另一种选择:jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8,这个是解决中文乱码输入问题,当然也可以和上面的一起结合:jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC
另一种情况改成:jdbc:mysql://localhost:3306/test?serverTimezone=GMT 之后才行。
jdbc是mysql-connector-java-8.0.11.jar,设置过时区 set time_zone = ‘+8:00’
总结:出现这个问题先看自己系统设置的时区是UTC还是GMT,再找对应的解决办法
[08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.的更多相关文章
- [08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up IDEA2019的database插件无法链接mysql的解决办法(08001错误)
[08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up. 点击这里 ...
- pycharm2019连接mysql错误08801 ------Connection to django1@localhost failed. [08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.
Error:Connection to django1@localhost failed. [08001] Could not create connection to database server ...
- pycharm连接mysql是出现Connection to orm02@127.0.0.1 failed. [08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.
下面这个问题反正我是遇到了,也是难为我好几天,于是我决定发一个教程出来给大家看看!希望能帮助你们 原因: 可能是数据库的版本与本机装的驱动不匹配导致的, 解决方案一: 在 url 后面街上一句 因为笔 ...
- pycharm2019连接mysql错误:08801 ------Connection to django1@localhost failed. [08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.
- IntelliJ IDEA连接不上数据库 (Connection to testdb@localhost failed. [08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.)
问题提示为: 原因:MySQL数据库版本为8.0以上,需要在URL加上时区,即加上?serverTimezone=GMT 成功后为:
- 通过dbcp链接池对数据库操作报 Cannot create PoolableConnectionFactory (Could not create connection to database server. Attempted reconnect 3 times. Giving up.)--解决方案
org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for ...
- Could not create connection to database server. Attempted reconnect 3 times. Giving up.错误
项目是基于springboot框架,昨天从git上pull代码之后也没有具体看更改的地方,结果运行的时候就报错了. java.sql.SQLNonTransientConnectionExceptio ...
- 解决idea中mysql连接失败Could not create connection to database server. Attempted reconnect 3 times. Giving up.
原因是少一个参数,设置时区的. 解决方法: 加一个参数: serverTimezone=UTC jdbc:mysql://localhost:3306/SshProject?useUnicode=t ...
- Could not create connection to database server. Attempted reconnect 3 times. Giving up.
报出这个错误,可能原因: 1.检查MySQL数据库服务是否正常(包含检查服务名和密码),如果不正常,修复至正常为止: 2.maven工程中导入的mysql的jar版本和你的MySQL版本不相符,必须相 ...
随机推荐
- 使用win10自带虚拟光驱打开ISO镜像文件
使用win10自带虚拟光驱打开ISO镜像文件非常的简单. 工具/原料 电脑 win10系统 方法/步骤 第一种方法,双击ISO文件.打开“我的电脑”,打开所要打开的ISO文件所在的目录,双击要 ...
- Linux的docker安装solr并创建core
查看solr列表 docker search solr 拉取solr镜像[注:这里默认latest],由于之前下载过 docker pull solr 启动一个做了端口映射的solr[-d:后台运行, ...
- L2R 二:常用评价指标之AUC
零零散散写了一些,主要是占个坑: AUC作为一个常用的评价指标,无论是作为最后模型效果评价还是前期的特征选择,都发挥着不可替代的作用,下面我们详细介绍下这个指标. 1.定义 2.实现 # coding ...
- 前端开发 Vue Vue.js和Nodejs的关系
首先vue.js 是库,不是框架,不是框架,不是框架. Vue.js 使用了基于 HTML 的模版语法,允许开发者声明式地将 DOM 绑定至底层 Vue 实例的数据. Vue.js 的核心是一个允许你 ...
- Widget Size and Position !!!!!!!!!!!!!!!!!!
https://medium.com/@diegoveloper/flutter-widget-size-and-position-b0a9ffed9407 I have read many ques ...
- 常用 SQL*Plus 命令
一些常用的 SQL*Plus 命令: 一.Help 命令 SQL*Plus 提供了help 命令来帮助用户查询指定的命令的选项.help 可以向用户提供被查询命令的标题.功能描述.缩写形式和参数选项( ...
- Appscan漏洞之跨站点请求伪造(CSRF)
公司前段时间使用了Fortify扫描项目代码,在修复完这些Fortify漏洞后,最近又启用了Appscan对项目代码进行漏洞扫描,同样也是安排了本人对这些漏洞进行修复.现在,针对修复过的Appscan ...
- Vue props用法详解
Vue props用法详解 组件接受的选项之一 props 是 Vue 中非常重要的一个选项.父子组件的关系可以总结为: props down, events up 父组件通过 props 向下传递数 ...
- iOS 关键词assign、strong、copy、weak、unsafe_unretained
关键词assign.strong.copy.weak.unsafe_unretained 影响: 是否开辟新的内存 是否有引用计数增加 strong 指向并拥有该对象.其修饰的对象引用计数会 +1,该 ...
- SpringBoot+SpringCloud+vue+Element开发项目——集成Swagger文档
在pom.xml文件中添加Maven依赖 <!--swagger--> <dependency> <groupId>io.springfox</groupId ...