Connecting DataGrip to SQL Server Express LocalDB

First you need to check if you LocalDB instance is ready for connection. Locate SqllocalDB.exe and run the SqllocalDB.exe i command in terminal. You will see the list of available LocalDB instances on the server which you are connecting to.

01-console-info

Say we want to connect to the v11.0 instance. First we need to check its state by running SqllocalDB.exe i v11.0 command.

02-console-instance-info

As you can see by examining the State field, right now the instance is stopped. Remember that by default every LocaDB instance is terminated after several minutes of inactivity. This behavior can be changed, but now we need to start the instance by running SqllocalDB.exe s v11.0

03-console-instance-start

It’s ready, so let’s launch DataGrip.

Invoke the database view by pressing Alt+1 and click + to add a new datasource, then choose SQL Server (jTds).

newdatasource

In the connection window we first select LocalDB in the dropdown next to the URL field. Then we go to the Instance field and select the instance to connect to, in our case, v11.0.

localdbchoosing

Then, go to the Advanced tab and find the DOMAIN option and set it to the name of the machine where the instance is installed. If the instance is on your local machine, use the name of your computer.

domainchoosing

The only thing left to do is to enter the access credentials and then click Test connection.

testsonnection

Voila!

result

Your DataGrip Team
_
JetBrains
The Drive to Develop

 

This entry was posted in Tutorial and tagged , , . Bookmark the permalink.

3 Responses to Connecting DataGrip to SQL Server Express LocalDB

  1. Justin says:

    Thank you!!! :D
    I <3 JetBrains

  2. István Heckl says:

    Your description worked fine. But the opened DB contains system tables like spt_monitor, spt_fallback_dev. (sqllocaldb.exe showed only one local db)

    I have an mdf file which contains the DB I want to use. Any idea? (I tried to give the full name of the mdf file in the uppermost Database field, but it did not help)

    • Maksim Sobolevskiy says:

      Let me copy-paste your comment from SO to help those who will read it in future.

      “I found the solution:

      after giving username and password go to schema tab (exit from visual studio) check the mdf file, check the relevent schema, e.g. dbo if you missed this step then database double click on “connection / schemas” to make the check”

Leave a Reply

Your email address will not be published. Required fields are marked *