How to install and run Microsoft SQL Server on Mac and connect it to DataGrip
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.
4. Navigate to 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.
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
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.
3. Wait until it 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:
2. It will ask you for your admin password. Enter it.
If you receive a response like this one it means you have the 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 JetBrains’ DataGrip instead.
Now follow the steps below or alternatively you can go to JetBrains’ How to connect to MS SQL server.
- Navigate to File and choose Data Sources….
2. In the Data Sources and Drivers dialog, click the Add icon (+) and select SQL Server.
3. At the bottom of the data source settings area, 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:
8. To make sure that the connection to the data source is successful, 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.