Yes, you can install SQL Server on macOS, but not as a native application. Microsoft does not offer a macOS version of SQL Server; instead, you run SQL Server in a Docker container on your Mac. This guide walks you through the exact steps, prerequisites, and common pitfalls so you can get a working SQL Server instance on your Mac for development or learning.
Background: Why No Native macOS Version?
SQL Server is a relational database management system developed by Microsoft. Historically, it ran only on Windows. In 2017, Microsoft released SQL Server for Linux, which also enabled macOS support through containers. However, there is still no native macOS installer—Microsoft’s official recommendation for Mac users is to use Docker. This approach lets you run the same SQL Server engine (Linux-based) inside a lightweight virtualized environment. It’s perfectly suited for development, testing, and learning, but not for production deployments on a Mac.
Prerequisites: What You Need Before Starting
Before you begin, ensure your Mac meets these requirements:
- macOS version: Docker Desktop works on macOS 10.15 (Catalina) or newer, though newer versions may require macOS 11 or later. Check Docker’s official docs for the latest.
- Hardware: A Mac with an Intel processor or Apple Silicon (M1/M2/M3). Docker Desktop supports both, but Apple Silicon uses a different architecture, which may require additional configuration.
- Docker Desktop: Install the latest version from Docker’s website. It includes the Docker Engine, CLI, and a GUI.
- Command-line tools: You’ll use Terminal (or iTerm) for most steps. Basic familiarity with the command line is helpful.
- Disk space: The SQL Server image is about 1.5 GB, plus additional space for databases.
How It Works: SQL Server in a Docker Container
Docker containers are isolated environments that share the host OS kernel. For SQL Server, Microsoft publishes an official image named mcr.microsoft.com/mssql/server. When you run a container from this image, you get a full SQL Server instance listening on port 1433 (the default). The container is ephemeral, meaning any data stored inside it is lost when the container is removed. To persist data, you must mount a volume—a directory on your Mac that maps to a path inside the container. This way, your databases survive container restarts.
Step-by-Step Installation
Follow these steps to install and run SQL Server on your Mac:
- Install Docker Desktop if you haven’t already. Open the downloaded .dmg, drag Docker to Applications, and launch it. Wait until the Docker whale icon appears in the menu bar and says “Docker Desktop is running.”
- Open Terminal (or your preferred terminal emulator).
- Pull the SQL Server image by running:
docker pull mcr.microsoft.com/mssql/server:2022-latest
This downloads the latest SQL Server 2022 image. You can also specify a version like2019-latest. - Run the container with the following command, replacing
YourStrong!Passw0rdwith a strong password (at least 8 characters, including uppercase, lowercase, digits, and symbols):docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=YourStrong!Passw0rd" -p 1433:1433 --name sqlserver -d mcr.microsoft.com/mssql/server:2022-latest
This maps port 1433 of your Mac to the container’s port 1433, names the containersqlserver, and runs it in detached mode. - Verify the container is running with
docker ps. You should see a row with the image name and status “Up”. - Connect to SQL Server using a client tool. You can use
sqlcmdinside the container, or install a GUI tool like Azure Data Studio (free) or DBeaver. For a quick test, run:docker exec -it sqlserver /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P "YourStrong!Passw0rd" -C
If you see a1>prompt, you’re connected.
Persisting Data: Mounting a Volume
By default, any database you create inside the container is lost when you stop and remove the container. To keep your data, you must mount a host directory. Here’s how:
- Create a directory on your Mac, e.g.,
mkdir ~/mssql-data. - Run the container with a volume mount:
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=YourStrong!Passw0rd" -p 1433:1433 -v ~/mssql-data:/var/opt/mssql --name sqlserver -d mcr.microsoft.com/mssql/server:2022-latest
The-vflag maps the host directory to/var/opt/mssqlinside the container, where SQL Server stores data files. - Note for Apple Silicon (M1/M2/M3): If you get an error about “platform linux/amd64 not found,” you may need to add
--platform linux/amd64to thedocker runcommand. This is because the SQL Server image is built for Intel architecture, and Docker on Apple Silicon can emulate it, but it’s slower.
Connecting from GUI Tools
Once the container is running, you can connect from any SQL client that supports TCP/IP connections. The server is localhost (or 127.0.0.1), port 1433, username sa, and the password you set. Popular options include:
- Azure Data Studio – Microsoft’s free cross-platform tool, ideal for querying and managing databases.
- DBeaver – A universal database client that works with SQL Server.
- Visual Studio Code – With the “SQL Server (mssql)” extension, you can run queries directly from the editor.
In Azure Data Studio, create a new connection, enter localhost as the server name, choose “SQL Login” and enter sa and your password. You should see the system databases (master, model, msdb, tempdb) appear.
Common Problems and How to Fix Them
Here are typical issues you might encounter and their solutions:
- Port already in use: If port 1433 is occupied, change the host port, e.g.,
-p 14330:1433. Then connect usinglocalhost,14330(orlocalhost:14330in some tools). - Container exits immediately: Check logs with
docker logs sqlserver. Often it’s due to a weak password or not accepting the EULA. Ensure your password meets complexity requirements. - Connection refused: Make sure the container is running (
docker ps) and you’re using the correct port. Also, on macOS, localhost should work; if not, try127.0.0.1. - Apple Silicon performance: Emulation is slower. Consider using Azure SQL Database (cloud) or a lightweight alternative like PostgreSQL for local development if performance is critical.
- Data lost after container restart: You forgot to mount a volume. Stop the container, remove it (
docker rm sqlserver), and re-run with the-vflag as shown above.
Alternatives to SQL Server on macOS
If you need a relational database on your Mac and SQL Server isn’t a strict requirement, consider these options:
- PostgreSQL – A powerful open-source database that runs natively on macOS. Great for most applications and has excellent tooling.
- MySQL – Another popular open-source database, also native on macOS. Widely used in web development.
- SQLite – A file-based database, perfect for small projects and embedded use. No server setup required.
- Azure SQL Database – If you need the real SQL Server engine for production, you can run it in Microsoft’s cloud and connect from your Mac. This is a good option if you don’t want to manage Docker.
Each has its own strengths, so choose based on your project needs and deployment environment.
Frequently Asked Questions
Can I install SQL Server directly on macOS without Docker?
No, Microsoft does not provide a native macOS installer. Docker is the official and recommended way to run SQL Server on a Mac. There are also unofficial methods using virtual machines (like VMware or Parallels) running Windows or Linux, but those are heavier and more complex.
Is SQL Server on macOS free?
Yes, the Docker image is the free Developer edition, which includes all features for development and testing. For production use, you would need a licensed edition, but for learning and development, it’s free.
How do I stop and restart the SQL Server container?
To stop the container, run docker stop sqlserver. To restart it, run docker start sqlserver. Your data will persist if you mounted a volume. If you didn’t, any databases created will be lost when the container is removed (but not when it’s just stopped).
Can I use SQL Server Management Studio (SSMS) on macOS?
No, SSMS is Windows-only. On macOS, you can use Azure Data Studio, which is Microsoft’s cross-platform tool and provides a similar experience for most tasks. Alternatively, you can use a Windows virtual machine to run SSMS, but that’s overkill for most users.
What is the default SA password? I forgot mine.
You set the SA password when you first ran the container. If you forgot it, you can reset it by running a new container with a new password, but you’ll lose any databases unless you mounted a volume. If you have a volume, you can mount it to a new container and reset the password using a more advanced procedure, but it’s often easier to start fresh.
Final Thoughts
Running SQL Server on macOS via Docker is straightforward and reliable for development. The key steps are installing Docker, pulling the image, and running a container with the right environment variables and port mapping. Remember to mount a volume for persistence and use a strong password. With these tools, you can develop and test SQL Server databases on your Mac without needing a Windows machine.
Related
General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.
More in this bed
- Extract SMS & iMessage from iTunes Backup
- View Saved Passwords on Samsung Galaxy Phones
- Messenger Calls Not Ringing: Fixes for Android & iPhone
- NordVPN Not Working on Windows 11? Fixes That Work
- Firestick vs Fire TV: Key Differences
- Kodi Crashing on Windows? Fixes That Work