I have been struggling to learn how the localhost MySQL and IntelliJ to connect and program a database related task. Is that Possible? If yes, how to achieve it?
-
1Can you be more specific about what you are wanting to learn? Do you want to know how to connect to mysql in general and open a console? Please elaborate a bit more. – James Wynn Jul 29 '16 at 15:26
-
1Hi James, Actually i have downloaded the intellij Ultimate.So previously I am from php envornment and so i have downloaded the mysql in my computer folder.So just we do in php we need to connect to the database and can store data from created sites, simmiliarly Is that possible in intellij.to connect to database locally.All tutorial telling about the connection to remote one? i also need want to know how to connect to mysql in general and open a console? – RAJMOHAN Jul 30 '16 at 04:25
6 Answers
Connecting to a local instance is essentially the same as connecting to a remote instance of MySQL. Just substitute either localhost, or 127.0.0.1 in place of the IP address you would use normally.
To add a new database connection (called a data source in IntelliJ), open the Database window View -> Tool Windows -> Databases, then click the + sign and select Data Source and then MySQL from the sub-menu. The defaults for the MySQL connection should for a local install of MySQL.
To open a connection, right click on your new data source and select Open Console.

- 686
- 6
- 6
As of Community version 2017.2, the DB Browser does not come bundled with the IDE
(at least not on my last two installations). In order to activate it, you should navigate in the IDE
in **File->Settings->Plugins->Browse repositories
and select "Database"
from the dropdown menu. From there you can install the Database Navigator. After the installation has been successful, you should restart the IDE
. Then you can select **View->Tool windows->DB Browser
.

- 2,445
- 2
- 21
- 31

- 514
- 5
- 13
In recent versions of Idea Community (about 2017.3, but I am not sure) there is no Database tool available anymore, only in Idea Ultimate [1]. Yet worse, the plugin Database Navigator that would fit here to solve this problem is not compatible anymore, at least not with 2018.3 [2].
Uninstalling Idea right now, unfortunately.

- 2,195
- 1
- 23
- 31
To add a new database connection (called a data source in IntelliJ), open the Database window View -> Tool Windows -> Databases, then click the + sign and select Data Source and then MySQL from the sub-menu. The defaults for the MySQL connection should for a local install of MySQL.
To open a connection, right click on your new data source and select Open Console.
to download Drivers click on "Download missing Drivers" in bottom of the window.
if you want to add JDBC and connect other database vendor like workbench projects (instead of using intelliJ Consol) just follow the steps bellow :
Using JDBC drivers #
Create a connection to a database with a JDBC driver # If you cannot find a name of a database vendor in the list of data sources, download a JDBC driver for the database management system (DBMS), and create a connection in IntelliJ IDEA. With the JDBC driver, you can connect to DBMS and start working.
In the Database tool window (View | Tool Windows | Database), click the Data Source Properties icon.
In the Data Sources and Drivers dialog, click the Add icon (+) and select Driver and Data Source.
Click the User Driver link.
In the Driver files pane, click the Add icon and select Custom JARs.
Navigate to the JAR file of the JDBC driver, select it, and click OK.
In the Class field, specify the value that you want to use for the driver.
Click Apply.
Return to the created data source connection.
Specify database connection details. Alternatively, paste the JDBC URL in the URL field. To set an empty password, right-click the Password field and select Set empty.
To ensure that the connection to the data source is successful, click Test Connection.
For more information read the official answer of Jetbrains in following link :

- 622
- 6
- 7
For anyone who is having trouble connecting IntelliJ Community Edition with MySQL in 2021. (In IntelliJ Ultimate Database connectivity is supported by default and you can follow the steps shown in the previous answers. However IntelliJ Community Edition does not support it by Default).
Here is what you have to do:
- Install "Database Navigator" Plugin. (Settings->Plugins->Marketplace->Search Database Navigator and install)
- Open DB Browser Tab (next to the button that opens/closes Project Window) -> Click Options logo -> '+' -> Fill the Database fields (Name, host, Port, DB Name, User and Password).
- Download the MySQL Java Connector by searching google for 'java connector mysql'.
- Go to File-> Project Structure -> Modules-> Dependencies. Click the '+' on the right side and select 'JARs or directories'. Navigate and find the Java connector you just downloaded (the file looks like this: mysql-connector-java-8.0.26.jar). Click apply and in the project window, under External Libraries, you will see the .jar file.

- 124
- 1
- 8
For WebStorm you need plugin "database-navigator" https://plugins.jetbrains.com/plugin/1800-database-navigator