Setting up SQL Server on a Mac with an Intel processor is possible with Docker. This guide walks you through pulling and running the SQL Server Docker image, connecting with SQL CLI, and using graphical database tools like Azure Data Studio or DBeaver.
Pulling the MSSQL Docker Image
To start, pull the SQL Server Docker image to your Mac:
sudo docker pull mcr.microsoft.com/mssql/server:2019-latest
Running the SQL Server Docker Container
Next, run a Docker container to create a SQL Server instance. Use a strong password for the system administrator (“sa”):
docker run -d --name sql_server_demo -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=SecureP@ssw0rd!' -p 1433:1433 mcr.microsoft.com/mssql/server:2019-latest
- Detached mode: The
-d
flag allows the container to run in the background. - Container name: The
--name
flag sets the container name tosql_server_demo
. - EULA acceptance: The
-e 'ACCEPT_EULA=Y'
accepts the SQL Server End-User License Agreement. - “sa” password: The
-e 'SA_PASSWORD=SecureP@ssw0rd!'
sets a strong system administrator password. Replace it with a secure, memorable one. - Port mapping: The
-p 1433:1433
maps the SQL Server port.
Installing SQL CLI
To interact with SQL Server via the command line, install SQL CLI (known as mssql
) using npm:
sudo npm install -g sql-cli
Ensure Node.js and npm are installed on your Mac. If not, install them via Homebrew or the Node.js website.
Step 4: Connecting with SQL CLI
To connect to SQL Server with SQL CLI, run the following command:
mssql -u sa -p SecureP@ssw0rd!
If successful, you’ll get a SQL command prompt to interact with SQL Server.
Using Azure Data Studio or DBeaver
You can now also use Azure Data Studio or DBeaver:
- Azure Data Studio: A cross-platform database tool from Microsoft, designed for SQL Server and other databases. Download it from the official Azure Data Studio site. Connect to SQL Server with
localhost
,sa
, and your password.
or
- DBeaver: A popular cross-platform database tool supporting various databases, including SQL Server. Download it from the DBeaver website. Connect to SQL Server by providing your connection details (hostname, port, username, and password).