无法通过DataGrip应用程序

时间:2017-05-11 11:32:53

标签: mysql docker connection datagrip

我已成功通过mysql命令行实用程序成功连接到运行MySQL的docker实例。但是,我正在努力通过JetBrains的DataGrip应用程序这样做。

我的mysql cli命令如下:

mysql -h127.0.0.1 --port=8181 -uroot

DataGrip中生成的连接字符串是:

jdbc:mysql://127.0.0.1:8181

我从DataGrip界面得到的错误是:

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

在DataGrip中是否需要更改我缺少的内容。我已经读过连接也必须通过TCP完成。不知道如何检查DataGrip是否正在这样做。

更新:我最终发现问题是我正在使用的docker容器。似乎DataGrip无法连接到版本8.0.1(mysql:8.0.1)的mysql docker容器。我使用容器的5.7版测试并且可以成功连接。

1 个答案:

答案 0 :(得分:6)

我在使用DataGrip连接MySQL 8.0.3时遇到了问题。您需要从Oracle website下载JDBC驱动程序。选择Developer Releases(因为这是一个不稳定的版本)。 8.0.8版本适合我。下载并保存在计算机上的项目文件夹或类似文件夹中。你以后会需要的。

  • 转到DataGrip:文件>数据源。点击+,然后选择Driver
  • Screenshot of the Step above
  • Driver Files>部分; Additional files点击+,然后选择刚下载的jar文件
  • 然后在Class下拉列表中选择com.mysql.jdbc.Driver
  • Dialect标记为MySQL
  • 在部分网址模板上,将名称设为default,将模板设为jdbc:mysql://{host::localhost}?[:{port::3306}][/{database}?][\?<&,user={user},password={password},{:identifier}={:identifier}>]
  • 点击“应用”

完成!

Screenshot of MySQL 8.0.3 running on Datagrip

使用新驱动程序添加新数据源。

如果您发现以下错误:

[01S00] The server time zone value 'PDT' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support

您可以对Advanced标签进行临时修复,并为serverTimezone设置UTC变量作为示例。

相关问题