Database Connection in PhpStorm

Curious as to how you can connect to your database directly from inside PhpStorm?

David Abiola
4 min readFeb 20, 2020
Photo by Frederick Tubiermont on Unsplash

JetBrains’ PhpStorm is a very powerful IDE built especially for PHP development and has grown in popularity among web developers of this language. It is my preferred choice of IDE for PHP based projects, and I’m pleased to share this with you, of the many benefits I enjoy using the IDE. I’m not sure how popular this particular feature is, but maybe one or two people will find it handy in their development process.

Here’s how —

Step 1 — Locate the Database tab and click to open menu

  • You probably have the menu docked in on the far right vertical bar as indicated below
  • Alternatively, you may have to undock the menu using the view item on the menu bar. Take a look below —

Step 2 — Now that we have the Database menu open, let’s create a new connection using the ‘+’ button indicated below —

Then we’ll select a data source from the popup menu. In my case, I’ll be choosing MySQL

Step 3 — Now let’s set up our database and drivers configuration variables

Most of the time, it's as simple as:

  • Database
  • User
  • Password

See what I mean in my example below —

When you’ve filled in your variables, you can click the Test Connection button to make sure everything checks out before applying these changes. If you get the green ‘Successful’ message (right beside the button), then you’re good to go. If not, you may need to review your details to make sure there’re no typos or mixups anywhere.

Since I got the green, I’ll just click the ok button below the pane.

Now, in the docked vertical menu, my database tables and columns should be loaded in a collapsible list inside the docked side menu like so:

Connection established!

Let's tinker around in our database

We can now interact with these tables and columns from right inside our IDE.

Double-clicking the posts item on the tables list opens up the table, and here I can make modifications directly in this table’s columns.

For instance —

  • If I wanted to delete the entire row 43 below, I’d just select the row, and click the ‘-’ in the menu (circled) above the table columns, and then post the changes with the up-arrow button to the right of the ‘-’ button.
  • I can also modify the content of any column and post the changes with the same up-arrow button described above.
  • And I can refresh the contents in view using the refresh button to the left of the ‘+’ button.

What if we needed to update our database connection properties down the line?

Well, that’s pretty straightforward also — just use the data source properties button (circled below).

Here’s what you get — that familiar pane! You can update what properties need updating; and bam! — you’re on track again.

And if you decided to delete this connection, you can use the ‘-’ button (circled below) in the menu on the top left side of the pane.

Click ‘ok’ and everything is okay again.

I’m David — A Nigerian software engineer, coffee drinker, and innovator. Thanks for tuning in!

--

--

David Abiola

Human & software engineer. Interested in ()=> {[Arts, Education, Music, Science, Tech, AI, co-Humans]};