Running SQL Server on a Macintosh
SQL Server is normally to be found only on Windows environments. However, it is possible to install a working version of SQL Server on a Macintosh.
On a Macintosh, you have 2 options for running SQL Server:
- Using a Virtual Machine (such as VirtualBox), run SQL Server Express on a Windows Virtual Machine.
- Using Docker, run the Linux version of SQL Server.
Docker is like a light virtual machine. Unlike a full virtual machine, it sets up an environment specific to your application, but uses the host machine’s resources for operating system work.
Docker was designed to run on Linux, and MacOS is not linux. However, Docker for Macintosh also includes its own Linux virtual machine, so it still does the job.
Microsoft have release preliminary versions of SQL Sever for Linux which can be freely downloaded and used with Docker for Macintosh.
Using Docker for Macintosh
See References below for links.
- Download & Install Docker
- Start the Docker Application
You will need to increase allocated memory to at least 4Gb:
Preferences 4Gb Memory
Getting & Using SQL Server
Get MSSQL Server
sudo docker pull microsoft/mssql-server-linux
sudo docker pull microsoft/mssql-server-linux:latest
Docker on Linux enables persistent storage, which is what you want if you want to keep your data from one session to the next. Unfortunately, this is not available for Docker on Macintosh.
However, there is an alternative solution, which involves creating a Data Volume. This works just as well.
Create a Data Volume:
docker create -v /var/opt/mssql --name mssql-data \
Start MSSQL Server with the Data Volume
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=[password]' -p 1433:1433 \ --volumes-from mssql-data \ -d --name mssql-server microsoft/mssql-server-linux
[password] is your password
\ at the end of a line above causes the next line to be a continuation. Otherwise the commands must be issued on a single line.
docker start mssql-server
Microsoft Documentation on Running SQL Server on Docker
Using Docker on the Macintosh