How to install and run Microsoft SQL Server on Mac and connect it to DataGrip

Evgeni Ivanov
5 min readMar 10, 2020

--

I. Installing Docker Desktop

If you already have Docker installed go to Step II. Pull the SQL Server 2017 Linux container image from Microsoft Container Registry

1. If you don’t have Docker Desktop installed on your Mac you need to go to docker and download it. In order to download it you need to to sign up for a Docker Hub.

2. Install Docker Desktop on your Mac. You can find more information about system requirements and how to install and run Docker Desktop on your Mac here.

3. After you have successfully installed it go to your Applications folder or Launchpad and start it. Now you should see a whale in your Status menus.

Docker Desktop is running
Docker Desktop is running

4. Navigate to Preferences…

Go to Docker Preferences…
Go to Docker Preferences…

Go to Advanced tab and make sure you give Docker more than 2GB of Memory. It’s better if you give it at least 4GB. Then press Apply & Restart.

Go to Advanced tab
Go to Advanced tab

If you need more information about Docker you can go and check Docker Documentation.

II. Pull the SQL Server 2017 Linux container image from Microsoft Container Registry

Now follow the steps below or alternatively you can go to Microsoft’s Quickstart: Run SQL Server container images with Docker.

1. Open the Terminal app and pull the SQL Server 2017 Linux container image from Microsoft Container Registry with the following command.

sudo docker pull mcr.microsoft.com/mssql/server:2017-latest
Pull the SQL Server 2017 Linux container image from Microsoft Container Registry
Pull the SQL Server 2017 Linux container image from Microsoft Container Registry

The previous command pulls the latest SQL Server 2017 container image. If you want to pull a specific image, you add a colon and the tag name (for example, mcr.microsoft.com/mssql/server:2017-GA-ubuntu). To see all available images, see the mssql-server Docker hub page.

2. It will ask you for your admin password. Enter it.

Enter your admin password to pull SQL Server 2017 Linux container image from Microsoft Container Registry
Enter your admin password to pull SQL Server 2017 Linux container image from Microsoft Container Registry

3. Wait until it is completely installed.

Download of the SQL Server 2017 Linux container image is started
Download of the SQL Server 2017 Linux container image is started
Downloading the SQL Server 2017 Linux container image
Downloading the SQL Server 2017 Linux container image
When download is complete it will extract some components
When download is complete it will extract some components
Wait until the SQL Server 2017 Linux container image is completely installed
Wait until the SQL Server 2017 Linux container image is completely installed

III. Run the SQL Server 2017 Linux container image with Docker

1. To run the container image with Docker, use the following command.

sudo docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<YourStrong@Passw0rd>" \    -p 1433:1433 --name sql1 \    -d mcr.microsoft.com/mssql/server:2017-latest

On your Terminal it should look like this:

Run SQL Server 2017 Linux container image
Run SQL Server 2017 Linux container image

2. It will ask you for your admin password. Enter it.

Enter your admin password to run SQL Server 2017 Linux container image
Enter your admin password to run SQL Server 2017 Linux container image

If you receive a response like this one it means you have the SQL Server 2017 Linux container image running.

SQL Server 2017 Linux container image running

If you need more information about SQL Server 2017 you can go and check Microsoft’s SQL Server Documentation.

IV. Connect DataGrip to SQL Server

You can’t install SQL Server Management Studio (SSMS) on Mac and that’s why we’re going to use JetBrainsDataGrip instead.

Now follow the steps below or alternatively you can go to JetBrains’ How to connect to MS SQL server.

  1. Navigate to File and choose Data Sources….
Navigate to File
Navigate to File
Choose Data Sources…
Choose Data Sources…

2. In the Data Sources and Drivers dialog, click the Add icon (+) and select SQL Server.

Data Sources and Drivers
Data Sources and Drivers
Select SQL Server
Select SQL Server

3. At the bottom of the data source settings area, click the Download missing driver files link.

Click the Download missing driver files link
Click the Download missing driver files link

4. In Host specify the host. You can use localhost.

5. In Port field put the same port that you used when running the SQL Server container image with Docker.

6. For User put the username you used when running the SQL Server container image with Docker.

7. For Password put the password you used when running the SQL Server container image with Docker.

Your configuration should look like this:

DataGrip SQL Server configuration on Mac

8. To make sure that the connection to the data source is successful, click Test Connection.

Click Test Connection

9. Click Apply and OK.

If you need more information about how to work with DataGrip you can go and check JetBrains’ Getting started with DataGrip.

--

--