Reputation: 515
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?
Upvotes: 32
Views: 123467
Reputation: 134
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:
Upvotes: 2
Reputation: 1
For WebStorm you need plugin "database-navigator" https://plugins.jetbrains.com/plugin/1800-database-navigator
Upvotes: 0
Reputation: 1039
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 :
Configuring database connections
Upvotes: 2
Reputation: 2295
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.
Upvotes: 3
Reputation: 514
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
.
Upvotes: 35
Reputation: 686
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.
Official IntelliJ Documentation - Managing Data Sources
Upvotes: 47