Get Started With SQL Server On macOS, Complete With A Native GUI

March 26, 2018

Get Started With SQL Server On macOS, Complete With A Native GUI

Abstract bloom, artist unknown.


Never did I think that I'd be able to run SQL Server on my Mac. My, how times have changed.

For the first time, SQL Server 2017 allows users to install the product on Linux. This opens the doors for working with fully-featured SQL Server database engines on macOS through freely distributable Docker containers. With the addition of a new graphical user interface that's in public preview, Mac users can now leverage the same industry-leading database platform that has previously only been available to Windows users, all on their local computer. Let me show you how to get started in three easy steps.

1. Install Docker

The first step is to install Docker. Start at Docker Desktop for Mac, and click the Get Docker button on the top right. That will download a disk image containing the application. Drag Docker.app into your Applications folder and double-click to launch. Look for the Docker icon in the top menu bar. When the animation stops, Docker is ready to go. Step one: done.

2. Pull the SQL Server 2017 Container

Next, start up Terminal.app. This is where you'll issue commands to Docker. Microsoft provides pre-configured images that include the Developer edition of SQL Server 2017 running on Ubuntu Linux. You can pull the most recent version with the following command:

test code with markdown backticks
test code
sudo docker pull microsoft/mssql-server-linux:2017-latest

After supplying your macOS Administrator password, the image is downloaded.

CREATE TABLE Customers (
  ID int,
  Name varchar(255)
);

Docker images need to be unpacked into containers, and a single image can be used to create as many identical containers as you'd like; just be sure to give them unique names. The following command will create a single container called sqlserver1 from the image you just downloaded. A couple of points:

sudo docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=YourStrong!Passw0rd' -p 1401:1433 --name sqlserver1 -d microsoft/mssql-server-linux:2017-latest

To verify that everything is working as intended, you can check the status of Docker's containers:

docker ps -a

You should see a line for the container and, hopefully, a status of "Up." If you see "Exited" here, go back and double-check that the previous commands were typed correctly. You can also try:

docker stop sqlserver1
docker start sqlserver1

to reset the server. With the container now running, you're done with step two.

3. Install SQL Operations Studio

Microsoft is in the beginning stages of developing a cross-platform graphical user interface for SQL Server called SQL Operations Studio. Though it's still in an early public preview, SQL Ops Studio is already showing promise as a robust, lightweight interface that brings the best of SQL Server Management Studio (a venerable workhorse, but sadly Windows-only) over to the Mac and Linux platforms. The Ops Studio GitHub page will be your source of information as the project progresses. Head over to the GitHub repository, scroll down to the first section of the README, and download the macOS zip containing the latest stable preview.

Upon Operations Studio's first launch, the Connection window will automatically prompt you for login credentials. Use localhost as the name of the server, SA as the username, and fill in the password that you established when the Docker container was created. Then press the Advanced button, and scroll through the properties list until you get to the General section. Fill in the port number of 1401 here, or whichever port you're passing to SQL Server's 1433 listening port. Press OK, then Connect.

That should connect and pass you back to the main interface. If you've ever seen Visual Studio Code, then you'll instantly recognize the interface.

Conclusion

And there you have it! SQL Server running natively on your Mac with a sleek GUI to boot. Happy querying!



Headshot of Adam Wilbert, a dapper man with a graying beard

Adam Wilbert is a LinkedIn Learning / Lynda.com author of over forty courses on SQL Server, Microsoft Access, database design and development, and mapping with ArcGIS. Come say "hi" on Mastodon: @awilbert@mastodon.social.