首页 > 其他 > 详细

解决Connection to Xxx@localhost failed.

时间:2019-09-05 19:57:53      阅读:161      评论:0      收藏:0      [点我收藏+]

解决:
Connection to jianshu@localhost failed. [08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.

原因

2019最新版本IDEA,Pycharm连接JDBC方式为Mysql6中的com.mysql.cj.jdbc.Driver,这个方法需要指定时区【serverTimezone】

driverClassName=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://localhost:3306/test?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=false
username=root
password=

老版本使用为Mysql5中的com.mysql.jdbc.Driver,不需要指定时区

driverClassName=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&useSSL=false
username=root
password=
没懂??? 看图

技术分享图片

解决方法

  1. 更新mysql,官网下载
    8.0+版本解决,我本地用的MySQL5.7懒得改了就不用这个办法了

  2. 设置连接Mysql方式为5.x版本
    技术分享图片

问题

1.1 问题描述

最近把IDEA升级到2019版本发现数据库一直连接不上,一直提示时区错误【mysql时区问题解决方法】,解决完后发现数据库显示已连接但是无法查看数据库内容
技术分享图片
网上找了资料才知道IJ大哥把2019版本的IDEA Pycharm连接方式都默认改为了com.mysql.cj.jdbc.Driver

### 1.2 报错截图
技术分享图片

解决

更改IDEA连接方式
技术分享图片

搞定?

解决Connection to Xxx@localhost failed.

原文:https://www.cnblogs.com/xmg520/p/11469182.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!