现象描述:

在JetBrains的系列产品中,database连接MySQL数据库时,如Idea、DataGrip、GoLand、Pycharm 等等,连接MySQL数据库时会出现如下提示:

[08001] Could not create connection to database server. Attempted reconnect 3 times.

连接失败的信息是:

[08001] Could not create connection to database server. Attempted reconnect 3 times.

原因分析:

  造成这个问题的原因是因为数据库驱动包的版本问题,与当前的数据库版本不兼容(我的是mysql5.7版本,而驱动是8.0的版本)

  还有一些其他的情况,如提示timeZone不正确(或者是一串乱码)等大部分都是驱动的问题。

问题解决:

方法一:针对版本问题

对于版本问题造成的不兼容的原因,我们可以替换数据库驱动包的版本,如图所以选择对应的Driver版本

[08001] Could not create connection to database server. Attempted reconnect 3 times.

测试——>成功

[08001] Could not create connection to database server. Attempted reconnect 3 times.

方法二:针对其他情况

对于这种问题,我们需要在链接的URL后面添加参数来屏蔽版本问题带来的影响,具体格式如下:

jdbc:mysql://localhost:3306/{youdatabasename}?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC

如图:

[08001] Could not create connection to database server. Attempted reconnect 3 times.

连接成功!

相关文章:

  • 2022-12-23
  • 2021-07-12
  • 2022-12-23
  • 2021-09-25
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
  • 2021-11-15
猜你喜欢
  • 2021-07-02
  • 2021-09-06
  • 2021-04-29
  • 2021-10-27
  • 2021-06-26
  • 2021-06-07
相关资源
相似解决方案