Connect to MySQL Data Source in PHPStorm

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.

Driver download failure

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

Manually add driver .jar


Short version:

  • Open the Database tab, usually located on the very upper right of PHPSTORM.
  • Click on the small wrench (Data Source and Property)
  • In this new popup window choose MySQL from the left.
  • Delete Red driver files with the minus symbol
  • Click Download

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

Detailed version:

  • Open the Database tab, usually located on the very upper right of PHPSTORM.
  • Click on the small wrench (Data Source and Property)

enter image description here New Version v2020: New Version 2020.1 If it's not there open it from View -> Tool Windows -> Database

view New Version v2020 New Version 2020.1 - In this new popup window choose MySQL from the left.

Should look like this New Version v2020: New Version (V 2020.1) - 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.

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)

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

  • 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

  • try other versions enter image description here New Version v2020: New Version 2020.1

Installing the Driver Manually

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

  • http://download.jetbrains.com/idea/jdbc-drivers/mysql-connector-java-5.1.35-bin.jar http://download.jetbrains.com/idea/jdbc-drivers/mysql-connector-java-5.1.40-bin.jar http://download.jetbrains.com/idea/jdbc-drivers/mysql-connector-java-5.1.44-bin.jar http://download.jetbrains.com/idea/jdbc-drivers/mysql-connector-java-5.1.45-bin.jar http://download.jetbrains.com/idea/jdbc-drivers/mysql-connector-java-5.1.46-bin.jar http://download.jetbrains.com/idea/jdbc-drivers/mysql-connector-java-5.1.47-bin.jar http://download.jetbrains.com/idea/jdbc-drivers/mysql-connector-java-5.1.48-bin.jar

The Newest version number can be found here: https://dev.mysql.com/downloads/connector/j/5.1.html

just replace the [VERSION] with the current version e.g. http://download.jetbrains.com/idea/jdbc-drivers/mysql-connector-java-[VERSION]-bin.jar

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

adding files New Version v2020: New Version (2020.1)

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

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.

Other stuff:

  • Useful phpstorm UI reference link

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.

After that it worked.


PHPStorm 2020.1 with Material Dark theme:

  1. Hit Alt+0 or View→Tool Windows→Database to open the Database tool window.
  2. Click the pancakes-with-wrench icon
  3. Click the TEST CONNECTION button
  4. This will prompt you to download the drivers - do it
  5. You will have to enter your root password again

enter image description here