SQL Server cannot be installed and run on macOS, but starting from SQL Server 2017, it supports Linux, so it can be run on macOS with Docker.
How to install Docker on macOS, please see the official documentation [Install Docker Desktop on Mac - https://docs.docker.com/docker-for-mac/install/](https://docs.docker.com/docker-for -mac/install/).
Docker can also be installed through the
brew package manager.
brew install --cask docker
For more information on
brew, see The Missing Package Manager for macOS (or Linux) — Homebrew - https://brew.sh/.
Pull SQL Server image
Execute the following command to pull SQL Server image:
sudo docker pull mcr.microsoft.com/mssql/server:2017-latest
Create and run the container using SQL Server image
Execute the following command to use the
mcr.microsoft.com/mssql/server:2017-latest image to create a container named sqlserver with port 1433.
sudo docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Passw0rd" \
-e "ACCEPT_EULA=Y"sets the ACCEPT_EULA variable to an arbitrary value to confirm acceptance of the End User License Agreement.
-e "SA_PASSWORD=Passw0rd"specifies a strong password with at least 8 characters that meets SQL Server password requirements.
-p 1433:1433maps a TCP port in the host environment (first value) to a TCP port in the container (second value).
--rmexits the container, the container will be deleted, which is convenient for temporary testing.
--name sqlserverspecifies a custom name for the container instead of using a randomly generated name.
For more information about SQL Server images, please refer to [Microsoft SQL Server - Ubuntu based images | Microsoft Artifact Registry - https://mcr.microsoft.com/en-us/product/mssql/server/about](https:/ /mcr.microsoft.com/en-us/product/mssql/server/about)
View container status
ps -e | grep sqlserver
You can check the SQL Server running log by executing the
docker logs command.
docker logs sqlserver
Connect to SQL Server inside the container
docker exec -itcommand to start an interactive `Bash Shell’ inside the running container:
docker exec -it sqlserver bash
sqlserver is the name specified by the
-–nameparameter when creating the container.
sqlcmdfor local connections inside the container. By default,
sqlcmdis not in the path, so the full path needs to be specified.
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "Passw0rd"
If successful, the sqlcmd command prompt
1>should be displayed.
Connect to SQL Server with visual tools such as DBeaver
How to install DBeaver on macOS, please refer to the official document Download | DBeaver Community - https://dbeaver.io/download/.
DBeaver can also be installed via the
brew package manager.
brew install --cask dbeaver-community