How to install SQL Server on MacOS

Introduction

SQL Server is a relational database management tool developed by Microsoft. It is available on Windows, Linux, macOS, and as a Docker deployment.

In this tutorial, we will show you how to install SQL Server 2019 as a Docker deployment on macOS Catalina.

How to install SQL Server on macOS

Prerequisites

  • A system running macOS Catalina
  • A user with administrator-level privileges
  • Access to the terminal window

Install and Configure Docker

1. Download the Docker Community Edition installation file from the official Docker download page. Depending on your hardware, select the appropriate link in the Get Docker Desktop for Mac section to start the download.

Download Docker using the link in the Get Docker Desktop for Mac section

2. Double-click the .dmg file to start the installation process. Once this is done, drag the Docker.app icon to your Application folder.

3. Launch Docker, then open the Docker drop-down menu and select Preferences.

Select Preferences from the Docker drop-down menu

4. Open the Resources tab on the left side of the Preferences screen. Increase the Memory value to 4.00 GB. Once you are done, click Apply & Restart to confirm the new settings:

Increase Docker memory usage in the Resources tab of the Preferences screen

Install SQL Server on Mac

Follow these steps to set up SQL Server as a Docker container:

Note: For more information, check out our guide to installing SQL Server on Windows 10. We also have a guide on installing SQL Server on Linux.

Step 1: Download the SQL Server Image

Run the following command in the terminal window to download the image for SQL Server 2019:

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

Step 2: Launch the SQL Server Image in Docker

To launch the image you downloaded in Docker, use:

docker run -d --name example_sql_server -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=Strong.Pwd-123' -p 1433:1433 mcr.microsoft.com/mssql/server:2019-latest

In the command above:

  • -d: Launches the docker container in daemon mode, allowing it to run in the background without a terminal window open.
  • --name: Sets a name for the Docker container. In this example, we are using example_sql_server.
  • -e 'ACCEPT_EULA=Y': Confirms you agree with the EULA (End User License Agreement) for Docker.
  • -e 'SA_PASSWORD=Strong.Pwd-123': Sets the database password. In this example, we are using "Strong.Pwd-123" as the password.
  • -p 1433:1433: Maps the container to the local port 1433.
  • mcr.microsoft.com/mssql/server:2019-latest: Selects an image file for Docker to use.

Note: If you get an error output with the message Microsoft(R) SQL Server(R) setup failed with error code 1. Please check the setup log in /var/opt/mssql/log for more information, try the launch command again with a stronger password.

Step 3: Check the SQL Server Docker Container

Check the status of the SQL Server Docker container with:

docker ps -a

If the <strong>STATUS</strong> column of the output for the container says Up, the container is running. If it reads Exited, the container is no longer running and requires troubleshooting.

Step 4: Install SQL Server Command-Line Tool

Use the following command to install sql-cli:

sudo npm install -g sql-cli

sql-cli is a command-line tool that allows you to run commands and queries for an SQL Server instance in the terminal window.

Note: sql-cli requires that you have NodeJs installed. If you don't, download it from the official NodeJS website.

Step 5: Connect to SQL Server

Connect to SQL Server by using the mssql command in the terminal window:

mssql -u sa -p Strong.Pwd-123

Where:

  • -u: Defines the username for connecting to the database. In this example, we are using the default username "sa".
  • -p: Defines the password for logging into the database. In this example, we are using "Strong.Pwd-123", which we selected while launching the SQL Server Docker container.

Conclusion

After following this tutorial, you should have SQL Server 2019 installed and ready to use on macOS Catalina as a Docker deployment.

Check out our article to ensure you are following Docker security best practices.

Was this article helpful?
YesNo
Aleksandar Kovačević
Aleksandar Kovacevic is an aspiring Technical Writer at phoenixNAP. With a background in both design and writing, he aims to bring a fresh perspective to writing for IT, making complicated concepts easy to understand and approach.
Next you should read
How to Install SQL Express Server
February 4, 2021

SQL Server Express is a light, feature-restricted version of Microsoft's SQL Server 2019. This tutorial will guide you through the process of installing, upgrading, or uninstalling your copy of SQL Server Express 2019.
Read more
What Is a Database Server & What Is It Used For?
May 31, 2021

A database server is a machine used to store the database and to manage data access and retrieval. Read this article to learn more about database servers, how they work, and to see some examples of database servers.
Read more
SQL vs NoSQL: What's the Difference?
August 25, 2020

There are two main types of database solutions: SQL and NoSQL. In this article, you will learn the key differences between these database types.
Read more
What Is NoSQL Database? – NoSQL Explained
June 17, 2020

The article provides a detailed explanation of what a NoSQL databases is and how it differs from relational databases. It focuses on the strengths and weaknesses of the non-relational database model using many practical examples.
Read more
  • © 2021 Copyright phoenixNAP | Global IT Services. All Rights Reserved.