Setting up IDEA
Intellij IDEA knows how to work with databases no worse than Workbench. It even has a dedicated Database tab in the right pane. If you click on it, you will see a picture:
![Mysql Connecting Intellij IDEA](https://cdn.codegym.cc/images/article/7e1904c9-2653-4acd-9740-62964d202ea6/1024.jpeg)
Let's try to connect to our database. To get started, click on the plus sign:
![Mysql Connecting Intellij IDEA 1](https://cdn.codegym.cc/images/article/26c67ffd-1e96-4650-99e4-d9a4a15f8249/1024.jpeg)
How do you like the list of supported databases? Impressive? Starting from Google Big Query and ending with Cassandra.
Connecting MySQL IDEA
But we are modest people, so we'll just choose MySQL. IDEA immediately suggests specifying the settings for connecting to the database:
![Mysql Connecting Intellij IDEA 2](https://cdn.codegym.cc/images/article/cf9b7fa6-1198-4e87-bf2f-4f43bc84ff36/800.jpeg)
There are even more of them than Workbench. Although everything you need is already indicated, maybe there is no login and password.
From the interesting: IDEA is written in Java, so it uses standard Java drivers to work with MySQL. That is, exactly those that our program will use when it sends queries to the MySQL server.
Therefore, feel free to click Download to download the missing drivers.
I also specified the login and password for our local server and then clicked on the Test Connection button:
![Mysql Connecting Intellij IDEA 3](https://cdn.codegym.cc/images/article/10d72907-db21-47a0-9120-79562df540c8/800.jpeg)
The connection was successfully established, so feel free to click OK.
Displaying the contents of the database
If you see this picture:
![Mysql Connecting Intellij IDEA 4](https://cdn.codegym.cc/images/article/37300b8f-66ba-4007-8813-89a06dceb6fc/1024.jpeg)
Then click on the place highlighted in red and select the list of schemes manually. I specified 3: test, test2 and supershop and this is what I see now:
![Mysql Connecting Intellij IDEA 5](https://cdn.codegym.cc/images/article/259904ac-d632-441a-9d5f-fbd9d0b38544/1024.jpeg)
All three of my diagrams are in place. Let's see what we have in the user table:
![Mysql Connecting Intellij IDEA 6](https://cdn.codegym.cc/images/article/0580417a-caee-42b3-8103-0055db36a6bd/1024.jpeg)
Well, I already knew what columns we have there, but how to see the data?
Display table content
I just double clicked on the table name and IDEA showed me this:
![Mysql Connecting Intellij IDEA 7](https://cdn.codegym.cc/images/article/01c314f3-2f57-45a7-a2ac-71332bb06dd3/1024.jpeg)
So far, it looks much more interesting than in Workbench. The data was immediately displayed, and besides, there are service fields WHERE and ORDER BY. So that you can filter and sort data right on the spot.
Let's try to sort our table by level...
As soon as I started writing the word level, IDEA immediately offered me a great list of hints:
![Mysql Connecting Intellij IDEA 8](https://cdn.codegym.cc/images/article/11897f5a-5a52-4945-a7e1-056737ab72db/1024.jpeg)
Perhaps it looks more interesting than working through Workbench, he didn’t give out any special hints.
I typed level, hit enter, and voila, the table is sorted:
![Mysql Connecting Intellij IDEA 9](https://cdn.codegym.cc/images/article/d28c3376-44fe-4834-9a33-ae3e01ea9a25/1024.jpeg)
Okay, now I want to execute an arbitrary query without binding to a table, where can I do it?
We return to the panel on the right - there is a special button there to open the Query Console:
![Mysql Connecting Intellij IDEA 10](https://cdn.codegym.cc/images/article/d162e79a-bcb5-42ae-9a8e-9ea764a86929/1024.jpeg)
And we start writing a query:
![Mysql Connecting Intellij IDEA 11](https://cdn.codegym.cc/images/article/abcc2597-15ff-4389-9755-4ae84fa24548/1024.jpeg)
Auto tips from IDEA, as always, on top . And here is the result of our query:
![](https://cdn.codegym.cc/images/article/61ea88b1-dd75-4e98-8b91-9b6c5f43b9d4/1024.jpeg)