You can install Microsoft SQL Server on Windows and Linux Operating Systems. However, you can use the docker system to install it on MacOS.

Prerequisites

You can check this link to install Docker Desktop.

Steps to install MS SQL Server on docker

Step 1: Open a terminal and pull a docker image for Microsoft SQL Server. I will install the 2022 edition here.

docker pull mcr.microsoft.com/mssql/server:2022-latest

Step 2: Create and run a container from the image.

docker run -p 1433:1433 -d -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=aStrongPass123' --name mssql_server mcr.microsoft.com/mssql/server:2022-latest
Explanation
  • -p: port binding
  • -d: Deamon Mode, which allows you to run in the background.
  • -e 'ACCEPT_EULA=Y': You are accepting the End-User Licence Agreement.
  • -e 'SA_PASSWORD=aStrongPass123': Sets a strong password.

Step 3: Install SQL CLI to connect

You can now install a cross-platform command line interface for SQL Server.

npm install -g sql-cli

Step 4: Test your installation

mssql -u sa -p aStrongPass123