Ubuntu

How to Install Jetbrains DataGrip on Ubuntu

DataGrip is a SQL database IDE from JetBrains. It has auto completion support for SQL language. It even analyzes your existing databases and helps you write queries faster. DataGrip can be used to manage your SQL databases graphically as well. You can also export your database to various formats like JSON, CSV, XML etc. It is very user friendly and easy to use.

In this article, I will show you how to install DataGrip on Ubuntu. The procedure shown here will work on Ubuntu 16.04 LTS and later. I will use Ubuntu 18.04 LTS in this article for demonstration. So, let’s get started.

Installing DataGrip:

On Ubuntu 16.04 LTS and later, the latest version of DataGrip is available as a snap package in the official snap repository. So, you can easily install DataGrip on Ubuntu 16.04 LTS and later.

To install DataGrip snap package on Ubuntu 16.04 LTS and later, run the following command:

$ sudo snap install datagrip --classic

As you can see, DataGrip is being installed.

DataGrip is installed.

Initial Configuration of DataGrip:

Now, you can start DataGrip from the Application Menu of Ubuntu. Search for datagrip in the Application Menu and you should see the DataGrip icon. Just click on it.

As you’re running DataGrip for the first time, you will have to do some initial configuration. From this window, select Do not import settings and then click on OK.

Now, you will see the activation window. DataGrip is not free. To use DataGrip, you will have to buy it from JetBrains. Once you buy it, you will be able to use this window to activate DataGrip.

If you want to try out DataGrip before you buy it, select Evaluate for free and click on Evaluate.

DataGrip is being started.

Now, you will have to customize DataGrip. From here, select an UI theme. You can either use Darcula dark theme from JetBrains or the Light theme depending on your preferences. Just, select the one you like.

If you don’t want to customize DataGrip now, instead leave the defaults, then click on Skip Remaining and Set Defaults.

Otherwise, click on Next: Database Options.

Now, select the default SQL dialect. For example, if you mostly use MySQL, then, you should select MySQL. You may also set the default script directory for your chosen database dialect. It’s optional.

Once you’re done, click on Start using DataGrip.

DataGrip should start. You may click on Close to close to Tip of the Day.

This is the main window of DataGrip.

Connecting to a Database:

In this section, I will show you how to connect to a SQL database with DataGrip.

First, from the Database tab, click on the + icon as marked in the screenshot below.

Now, from Data Source, select the database you want to connect to. I will pick MariaDB.

As you are running DataGrip for this database (MariaDB in my case) for the first time, you will have to download the database driver. You can click on Download as marked in the screenshot below to download the database driver.

As you can see, the required database driver files are being downloaded.

Once the driver is downloaded, fill in all the details and click on Test Connection.

If everything is alright, you should see a green Successful message as shown in the screenshot below.

Finally, click on OK.

You should be connected to your desired database.

Creating Tables with DataGrip:

You can create tables in your database graphically using DataGrip.  First, right click your database from the list and go to New > Table as marked in the screenshot below.

Now, type in your table name. To add new columns to the table, click on + icon as marked in the screenshot below.

Now, type in the column name, type, default value if it does have in your design, and check the column attributes such as Auto Increment, Not null, Unique, Primary key depending on your need.

If you want to create another column, just click on the + icon again. As you can see, I created id, firstName, lastName, address, age, phone, and country columns. You can also use the icon to remove a column, Up and Down arrow icons to change the position of the column. Once you’re satisfied with your table, click on Execute.

Your table should be created.

You can double click on the table to open it in a graphical editor. From here, you can add, modify, delete table rows very easily. This is the topic of the next section of this article.

Working with Tables in DataGrip:

To add a new row, from the table editor, just click on the + icon as marked in the screenshot below.

A new blank row should show up.

Now, click on the columns and type in the values that you want for the new row. Once you’re done, click on DB upload icon as marked in the screenshot below.

As you can see, the changes are saved permanently in the database.

I added another row of dummy data just to demonstrate how delete and modify works.

To delete a row, select any column of the row you want to delete and click on the icon marked in the screenshot below.

As you can see, the row is not in gray color. To save the changes, click on the DB upload icon as marked in the screenshot below.

As you can see, the table is gone.

To edit any row, just double click on the column of the row that you want to edit and type in the new value.

Finally, click somewhere else and then click on DB upload icon for the changes to be saved.

Running SQL Statements in DataGrip:

To run SQL statements, just type in the SQL statement, move the cursor to the end of the SQL statement and press <Ctrl> + <Enter>. It will execute and the result will be displayed as you can see in the screenshot below.

So, that’s how you install and use DataGrip on Ubuntu. Thanks for reading this article.

About the author

Shahriar Shovon

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.