How to install SQL Server for Mac [Every detail covered]

355.0K views
8 min read

Did you hear that installing SQL Server on macOS is tricky? That’s not entirely true. While it’s a bit more challenging than on Windows, it should take you no more than 15 minutes anyway. In this post, I’ll explain how to install and set up Microsoft SQL Server on your Mac, step by step, in a way that even a kid could follow.

Step 1. Install and config Docker

Microsoft developed SQL Server for Windows, which means to run it on Mac, you’ll need an additional tool. Docker is just the software for the task as it provides an environment for your SQL Server to work in.

Here’s how to install Docker on your Mac.

  1. Download Docker from the official website and install it.
  2. Open Docker and agree to the terms. During the setup, you’ll need to install a helper tool, so your Mac will ask for your password to confirm the action.
  3. Sign up for the app. Here's what you'll see:

Step 2. Install SQL Server on Mac

Now you are ready to download, set up, and run SQL Server on Mac.

  1. Open Terminal.
  2. Type docker pull mcr.microsoft.com/mssql/server:2022-latest and hit Enter. The command execution will take about 5 minutes to complete.

3. Launch your downloaded SQL Server image in Docker. To do this, use the following command in Terminal, replacing the text in bold with your own data: docker run --name [your desired SQL Server name] -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=[password for your database]' -e 'MSSQL_PID=[your Docker membership type]’ -p 1433:1433 -d mcr.microsoft.com/mssql/server:2022-latest

Here is the command I used. The text in bold indicates where you should insert your information.

docker run --name SQLServer -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=12345OHdf%e' -e 'MSSQL_PID=Express -p 1433:1433 -d mcr.microsoft.com/mssql/server:2022-latest

SQL Server should be running on your machine now. To check, click the Docker icon in your menu bar and go to Dashboard. Here's my container:

Step 3. Install Azure Data Studio

Now, you need to download and install Azure Data Studio. This tool is the Mac equivalent for SQL Server Management Studio (SSMS).

  1. Download Azure Data Studio from the official Microsoft website and open it.
  2. Click Create a connection and fill in the boxes.
  • Server — since SQL Server is running on your own Mac, the server here is just localhost.
  • Authentication type — SQL Login (choose it from the drop-down list).
  • User name — SA (for system admin).
  • Password — the one you’ve entered in the Terminal command to run SQL Server with Docker. That’s 12345OHdf%e in my example.

Here's what you should get:

3. Press Connect. If you receive a connection error notification, press "Enable Trust Server Certificate."

If everything worked fine, your database is now ready for management:


How to check if SQL Server works properly

If you are able to connect to your running SQL Server in Azure Data Studio, SQL Server should be fully operational.

To test it out, get a sample database from Microsoft and run a few queries. I’ve used the AdventureWorks2022.bak database that corresponds to my SQL Server version. Make sure to select the database version that coincides with your SQL Server version, in my example it’s mcr.microsoft.com/mssql/server:2022-latest, so I used AdventureWorks2022.bak OLTP data file.

adventureworks database

  1. Download the database file and move it to a new system folder for Docker to be able to access (you can also leave it in Downloads).
  2. Open the Terminal and access the file. If it is in the Downloads folder, move it there with the cd Downloads/ command.
  3. Create a new directory for your database file with sudo docker exec -it SQLServer mkdir var/opt/mssql/backup command.
  4. Move your database to the new directory with >sudo docker cp AdventureWorks2022.bak SQLServer:var/opt/mssql/backup command.
  5. Now, open Azure Data Studio and enable the Restore feature. For this, go to Azure Data Studio > Settings > Settings > Workbench, and choose Enable Preview Features.

6. Return to localhost and click the arrow to expand the menu, and access the Databases folder (see the screenshot above).

7. Right-click on Databases and select Restore Database (Preview).

8. In the window that appears from the "Restore from" drop-down menu, select Backup file.

9. Click on three dots next to "Backup file path" and from there navigate to: var/opt/mssql/backup/AdventureWorks2022.bak

10. Confirm your choice and click Restore. 

Now you are ready to test SQL database connection with a few test queries. To do that, just select your newly added sample database and click New Query.

Tools for managing databases

Now that you’ve completed your SQL Server setup, it’s time to think about managing your databases.

SQLPro Studio is one of the tools I can recommend. The app excels at all the database management basics that you need — create tables, make custom queries, use autocomplete, and more with this handy tool. SQLPro Studio is a native Mac app and supports multiple database types, including MySQL, PostgreSQL, Microsoft SQL Server, and others.

TablePlus is another app that can help you manage SQL databases. This GUI tool will come in handy for your MySQL, Postgre, SQLite, and other databases. Lightweight and fast, it's super easy to use and makes your databases work lightning fast. Navigate your connected databases, edit data rows or table structure, and more with TablePlus.

TablePlus app

Base is an easy app with a spreadsheet-like interface that simplifies SQLite file management and eliminates the need to learn complex SQL commands. Its core features include easy SQLite database creation, instant and consistent data filtering, basic import and detailed export options, smart autocomplete, and more.

Try tools for managing SQL databases for free

As you see, installing SQL Server on your Mac is quick and easy, although it requires a virtualization tool, Docker. Since SSMS is not available for macOS, you’ll also need a replacement, which in our article was Azure Data Studio. The tool allows you to connect SQL Server engines to databases, even on macOS.

To manage and edit your databases, you can use specialized tools like SQLPro Studio or TablePlus. Both are available with your Setapp subscription, along with other tools for working with SQL databases, including SQLPro for SQLite and Base for SQLite.

Try these and more tools for daily productivity on Setapp. Start your 7-day free Setapp trial now!

FAQ

Can you run SSMS on Mac?

No, SQL Server Management Studio only runs on Windows. For macOS, Microsoft recommends using Azure Data Studio.

How do I access an SQL Server database on Mac?

In order to work with SQL databases on Mac, you need to use a virtualization tool like Docker, pull an SQL server image and run it, and then connect it to your Mac with a helper tool. You can do that with Azure Data Studio, or  use other tools for the task. Run Azure Data Studio restore tool to add an existing database and check your SQL database connection with a few test queries.

How do I check SQL database status?

To check your SQL database status, you can use DATABASEPROPERTYEX function:

How do I test an SQL database connection?

Get a sample database from Microsoft (e.g., AdventureWorks2022.bak) and run a few queries.

250+ apps for $9.99
per month

Sign up to Setapp and try them for free.

Security-tested