SQL Server Documentation

Install SQL Server on macOS

This guide walks you through installing SQL Server 2022 on macOS using Docker. The steps are tested on macOS Monterey (12.x) and later.

Prerequisites
Installation
Configuration
Troubleshooting

Prerequisites

  1. macOS 12.0 or newer.
  2. Apple Silicon (M1/M2) or Intel processor.
  3. Docker Desktop for Mac installed.
    Download Docker Desktop
  4. At least 4 GB of free RAM and 2 GB of disk space.

Installation Steps

  1. Open Terminal and pull the latest SQL Server image:
    docker pull mcr.microsoft.com/mssql/server:2022-latest
  2. Create a Docker volume for data persistence:
    docker volume create sqlserver-data
  3. Run the container:
    docker run -e "ACCEPT_EULA=Y" \
       -e "MSSQL_SA_PASSWORD=YourStrong!Passw0rd" \
       -p 1433:1433 \
       --name sqlserver \
       -v sqlserver-data:/var/opt/mssql \
       -d mcr.microsoft.com/mssql/server:2022-latest
  4. Verify the container is running:
    docker ps -f name=sqlserver
  5. Connect using sqlcmd (installed via Homebrew) or any GUI client.

Basic Configuration

  • Change the SA_PASSWORD after first login.
  • Enable remote connections (default port 1433 is already exposed).
  • Set up backups by mapping a host directory:
    docker run -v /Users/youruser/sql-backups:/var/opt/mssql/backup ...

Troubleshooting

If the container fails to start, run:

docker logs sqlserver

Common issues:

  • Memory limit: Increase Docker Desktop memory allocation.
  • Port conflict: Ensure no other service uses port 1433.
  • Authentication error: Verify SA_PASSWORD meets complexity requirements.

Next Steps