在PHPStorm中连接到MySQL数据源

时间:2022-10-15 18:34:30

I'm using an IDE "Phpstorm" with "wampserver". i want to connect with MySQL data source, but i'm getting a problem:

我使用IDE“Phpstorm”和“wampserver”。我想连接MySQL数据源,但是我遇到了一个问题:

Connection to MySQL - DatabaseName@localhost failed: Exception in thread "main" java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at com.intellij.persistence.database.console.RemoteJdbcServer.main(RemoteJdbcServer.java:15)

I also downloaded mysql-connector-java-gpl-5.1.29.msi and installed it, but I'm still getting some problems.

我也下载mysql-connector-java-gpl-5.1.29。msi和安装它,但我仍然有一些问题。

6 个解决方案

#1


50  

When I had this issue, there was a section of the Data Sources and Drivers Dialogue box that said "Driver Files" I expanded it and there was a link to download driver files.

当我遇到这个问题时,数据源和驱动对话框中有一个部分写着“驱动文件”我对它进行了扩展,还有一个下载驱动文件的链接。

I clicked it - and after a few seconds (with no obvious visual progress indicator) the message changed to say using MySQL drivers.

我点击了它——几秒钟后(没有明显的可视进度指示),消息改为使用MySQL驱动程序。

After that it worked.

在这工作。

#2


16  

Short version:

短版:

  • Open the Database tab, usually located on the very upper right of PHPSTORM.
  • 打开数据库选项卡,通常位于PHPSTORM的右上角。
  • Click on the small wrench (Data Source and Property)
  • 点击小扳手(数据源和属性)
  • In this new popup window choose MySQL from the left.
  • 在这个新的弹出窗口中,从左边选择MySQL。
  • Delete Red driver files with the minus symbol
  • 删除红色驱动程序文件与负符号
  • Click Download
  • 点击下载

From there on you should be good to go. (phpstorm handles the rest)

从那以后你应该可以去了。(其余phpstorm处理)

Detailed version:

详细的版本:

  • Open the Database tab, usually located on the very upper right of PHPSTORM.
  • 打开数据库选项卡,通常位于PHPSTORM的右上角。
  • Click on the small wrench (Data Source and Property)
  • 点击小扳手(数据源和属性)

在PHPStorm中连接到MySQL数据源

If it's not there open it from View -> Tool Windows -> Database

如果没有从视图->工具窗口->数据库打开它。

在PHPStorm中连接到MySQL数据源

  • In this new popup window choose MySQL from the left.
  • 在这个新的弹出窗口中,从左边选择MySQL。

在PHPStorm中连接到MySQL数据源

  • Now you should be on the settings tab where you can see driver files, if any of them are red just delete them with the minus symbol, as soon as there are no driver files left you are able to click on download.
  • 现在你应该在settings选项卡上,你可以看到驱动文件,如果任何一个是红色的,只要用负号删除它们,只要没有驱动文件,你就可以点击下载。

If any of the above fail try these:

如果以上任何一项都失败了,请尝试以下方法:

  • Delete the drivers in use and reinstall. Usually located at ~/.PhpStormXXXX/config/jdbc-drivers. After that repeat the first instructions in this post. (short version)

    删除正在使用的驱动程序并重新安装。通常位于~ / .PhpStormXXXX / config / jdbc驱动程序。然后重复这篇文章中的第一个说明。(短版)

  • Using a proxy? Make sure you have configured it within phpstorm! At Appearance & Behavior -> System Settings -> HTTP Proxy.

    使用一个代理?确保您已经在phpstorm中配置了它!在外观和行为->系统设置-> HTTP代理。

  • Make sure you have the latest drivers: Create a new mysql datasource, if the driver needs an update it will display it on the very bottom of the popup

    确保您有最新的驱动程序:创建一个新的mysql数据源,如果驱动程序需要更新,它将显示在弹出窗口的最底部

  • try other versions 在PHPStorm中连接到MySQL数据源

    尝试其他版本

Installing the Driver Manually

手动安装驱动程序

I couldn't find any official Jetbrains mysql driver repo page, but these urls are official and work:

我找不到任何官方的Jetbrains mysql驱动程序repo页面,但是这些url是官方的,而且有用:

Add the downloaded file with clicking on the small grey plus. (in older versions green and on the right)

添加下载的文件与点击小灰色plus。(旧版本的绿色和右边)

在PHPStorm中连接到MySQL数据源

Or try the official mysql repo (caution you MUST register to download!):

或者试试官方的mysql repo(提醒你必须注册下载!)

Go to http://dev.mysql.com/downloads/connector/ within the dropdown select "Platform Independent" it will show you the options to download tar or zip files. Download one of them and extract it, Within the resulting folder you will find a mysql-connector-XXX.jar file. Add it to phpstorm in the mysql datasource dialog box.

到http://dev.mysql.com/downloads/connector/下拉菜单中选择“平*立”,它将显示下载tar或zip文件的选项。下载其中一个并提取它,在结果文件夹中您将找到一个mysql-connector-XXX。jar文件。将它添加到mysql数据源对话框中的phpstorm中。

Other stuff:

其他的东西:

#3


1  

Code Monkey's answer pointed me in the right direction, but my firewall blocked the download from within PHPstorm. Luckily the error message included the download URL to find the driver.

Code Monkey的回答给我指明了正确的方向,但是我的防火墙阻止了PHPstorm内的下载。幸运的是,错误消息包含查找驱动程序的下载URL。

在PHPStorm中连接到MySQL数据源

So I downloaded the driver with help from the URL, and then added it manually:

所以我在URL的帮助下下载了驱动,然后手动添加:

在PHPStorm中连接到MySQL数据源

#4


0  

Had the same issue. I resolved it in the Data source and drivers window on panel Mysql. There is checkbox "Use provided driver" and next to it there was link "Version 5.1 (latest)". I clicked on it a now it works.

有同样的问题。我在Mysql面板的数据源和驱动窗口中解析了它。有一个复选框“使用提供的驱动程序”,旁边有一个链接“Version 5.1(最新版本)”。我点击了a,现在它工作了。

#5


0  

Anyone else who came here trying to locate the Database tab in the latest version of PhpStorm (Version 2017.1), which is hidden at first, try the following, taken from PhpStorm Website

任何来到这里试图在PhpStorm(第2017.1版)的最新版本中找到数据库选项卡的人,请尝试以下方法,这些选项来自PhpStorm网站

Database support is provided through the Database Tool Window on the right-hand side of the IDE. Use the View | Tool Windows | Database menu or Find Action, by pressing Ctrl+Alt+A (Alt-CMD-A on Mac OS X) and search for "Database" to open it.

数据库支持通过IDE右侧的数据库工具窗口提供。使用视图|工具Windows |数据库菜单或查找操作,按Ctrl+Alt+A (Mac OS X上的Alt- cmd -A),搜索“Database”打开。

#6


0  

if nothig of above works, you can delete .PhpStorm2017.3/config/jdbc-drivers folder. then navigate to your db properties and download the driver again

如果上面的nothig起作用,可以删除. phpstorm2017.3 /config/jdbc-drivers文件夹。然后导航到db属性并再次下载驱动程序

#1


50  

When I had this issue, there was a section of the Data Sources and Drivers Dialogue box that said "Driver Files" I expanded it and there was a link to download driver files.

当我遇到这个问题时,数据源和驱动对话框中有一个部分写着“驱动文件”我对它进行了扩展,还有一个下载驱动文件的链接。

I clicked it - and after a few seconds (with no obvious visual progress indicator) the message changed to say using MySQL drivers.

我点击了它——几秒钟后(没有明显的可视进度指示),消息改为使用MySQL驱动程序。

After that it worked.

在这工作。

#2


16  

Short version:

短版:

  • Open the Database tab, usually located on the very upper right of PHPSTORM.
  • 打开数据库选项卡,通常位于PHPSTORM的右上角。
  • Click on the small wrench (Data Source and Property)
  • 点击小扳手(数据源和属性)
  • In this new popup window choose MySQL from the left.
  • 在这个新的弹出窗口中,从左边选择MySQL。
  • Delete Red driver files with the minus symbol
  • 删除红色驱动程序文件与负符号
  • Click Download
  • 点击下载

From there on you should be good to go. (phpstorm handles the rest)

从那以后你应该可以去了。(其余phpstorm处理)

Detailed version:

详细的版本:

  • Open the Database tab, usually located on the very upper right of PHPSTORM.
  • 打开数据库选项卡,通常位于PHPSTORM的右上角。
  • Click on the small wrench (Data Source and Property)
  • 点击小扳手(数据源和属性)

在PHPStorm中连接到MySQL数据源

If it's not there open it from View -> Tool Windows -> Database

如果没有从视图->工具窗口->数据库打开它。

在PHPStorm中连接到MySQL数据源

  • In this new popup window choose MySQL from the left.
  • 在这个新的弹出窗口中,从左边选择MySQL。

在PHPStorm中连接到MySQL数据源

  • Now you should be on the settings tab where you can see driver files, if any of them are red just delete them with the minus symbol, as soon as there are no driver files left you are able to click on download.
  • 现在你应该在settings选项卡上,你可以看到驱动文件,如果任何一个是红色的,只要用负号删除它们,只要没有驱动文件,你就可以点击下载。

If any of the above fail try these:

如果以上任何一项都失败了,请尝试以下方法:

  • Delete the drivers in use and reinstall. Usually located at ~/.PhpStormXXXX/config/jdbc-drivers. After that repeat the first instructions in this post. (short version)

    删除正在使用的驱动程序并重新安装。通常位于~ / .PhpStormXXXX / config / jdbc驱动程序。然后重复这篇文章中的第一个说明。(短版)

  • Using a proxy? Make sure you have configured it within phpstorm! At Appearance & Behavior -> System Settings -> HTTP Proxy.

    使用一个代理?确保您已经在phpstorm中配置了它!在外观和行为->系统设置-> HTTP代理。

  • Make sure you have the latest drivers: Create a new mysql datasource, if the driver needs an update it will display it on the very bottom of the popup

    确保您有最新的驱动程序:创建一个新的mysql数据源,如果驱动程序需要更新,它将显示在弹出窗口的最底部

  • try other versions 在PHPStorm中连接到MySQL数据源

    尝试其他版本

Installing the Driver Manually

手动安装驱动程序

I couldn't find any official Jetbrains mysql driver repo page, but these urls are official and work:

我找不到任何官方的Jetbrains mysql驱动程序repo页面,但是这些url是官方的,而且有用:

Add the downloaded file with clicking on the small grey plus. (in older versions green and on the right)

添加下载的文件与点击小灰色plus。(旧版本的绿色和右边)

在PHPStorm中连接到MySQL数据源

Or try the official mysql repo (caution you MUST register to download!):

或者试试官方的mysql repo(提醒你必须注册下载!)

Go to http://dev.mysql.com/downloads/connector/ within the dropdown select "Platform Independent" it will show you the options to download tar or zip files. Download one of them and extract it, Within the resulting folder you will find a mysql-connector-XXX.jar file. Add it to phpstorm in the mysql datasource dialog box.

到http://dev.mysql.com/downloads/connector/下拉菜单中选择“平*立”,它将显示下载tar或zip文件的选项。下载其中一个并提取它,在结果文件夹中您将找到一个mysql-connector-XXX。jar文件。将它添加到mysql数据源对话框中的phpstorm中。

Other stuff:

其他的东西:

#3


1  

Code Monkey's answer pointed me in the right direction, but my firewall blocked the download from within PHPstorm. Luckily the error message included the download URL to find the driver.

Code Monkey的回答给我指明了正确的方向,但是我的防火墙阻止了PHPstorm内的下载。幸运的是,错误消息包含查找驱动程序的下载URL。

在PHPStorm中连接到MySQL数据源

So I downloaded the driver with help from the URL, and then added it manually:

所以我在URL的帮助下下载了驱动,然后手动添加:

在PHPStorm中连接到MySQL数据源

#4


0  

Had the same issue. I resolved it in the Data source and drivers window on panel Mysql. There is checkbox "Use provided driver" and next to it there was link "Version 5.1 (latest)". I clicked on it a now it works.

有同样的问题。我在Mysql面板的数据源和驱动窗口中解析了它。有一个复选框“使用提供的驱动程序”,旁边有一个链接“Version 5.1(最新版本)”。我点击了a,现在它工作了。

#5


0  

Anyone else who came here trying to locate the Database tab in the latest version of PhpStorm (Version 2017.1), which is hidden at first, try the following, taken from PhpStorm Website

任何来到这里试图在PhpStorm(第2017.1版)的最新版本中找到数据库选项卡的人,请尝试以下方法,这些选项来自PhpStorm网站

Database support is provided through the Database Tool Window on the right-hand side of the IDE. Use the View | Tool Windows | Database menu or Find Action, by pressing Ctrl+Alt+A (Alt-CMD-A on Mac OS X) and search for "Database" to open it.

数据库支持通过IDE右侧的数据库工具窗口提供。使用视图|工具Windows |数据库菜单或查找操作,按Ctrl+Alt+A (Mac OS X上的Alt- cmd -A),搜索“Database”打开。

#6


0  

if nothig of above works, you can delete .PhpStorm2017.3/config/jdbc-drivers folder. then navigate to your db properties and download the driver again

如果上面的nothig起作用,可以删除. phpstorm2017.3 /config/jdbc-drivers文件夹。然后导航到db属性并再次下载驱动程序