Yogesh Chauhan's Blog

Steps to Install Microsoft SQL Server on a MacOS

in SQL/MySQL on November 25, 2021

To have the Microsoft SQL server on your MacOS, you need to have Docker installed first. You’re basically gonna create an instance of the server on the Docker.

1. Download and Install Docker for Mac

Here’s a link to download the latest version of Docker for Mac: Install Docker Desktop on Mac

Once you download it, it’s easy to install. Open the downloaded .dmg file and drag and drop the Docker to the Applications folder. You should be instructed by the Docker installation guide.

2. Download SQL Server

The following command will download SQL server 2019 for Linux Docker image.

Run this command via terminal:

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

3. Launch the Docker

The following command will launch the Docker image we downloaded:

docker run -d --name sql_server_yc -e 'ACCEPT_EULA=Y' -e 'YC_PASSWORD=macSQL123' -p 1433:1433 mcr.microsoft.com/mssql/server:2019-latest

Breakdown of the command above:

-d: launches the Docker container in daemon mode (runs the command in the background), OPTIONAL

–name sql_server_yc: name the container, OPTIONAL

-e ‘ACCEPT_EULA=Y’: Yes(Y) to agree with the EULA (End User Licence Agreement)

-e ‘SA_PASSWORD=macSQL123’: set the database password

-p 1433:1433: maps the local port 1433 to port 1433 on the container

mcr.microsoft.com/mssql/server:2019-latest: Docker image to use

Use a stronger password if you get an error.

4. Install sql-cli

Run the following command to install the sql-cli command:

sudo npm install -g sql-cli

5. Connect to the SQL Server

mssql -u sa -p macSQL123

You should be in the mssql window now and you can run queries and perform database operations now.

6. Azure Data Studio installation

It’s way easier to see your data in tables visually rather than in terminal window. You can install Azure Data Studio install to have GUI for the SQL Server.

Here’s a link you can download Azure Data Studio from: Download and install Azure Data Studio

The installation is very simple. Unzip the downloaded file and move the file to the Applications folder.

7. Connect to SQL Server in Azure Data Studio

  1. Open Azure Data Studio
  2. Click on “New Connection”
  3. Add the credentials
    1. Server Name: localhost
    2. Authentication Type: SQL Login
    3. User name: sa
    4. Password: macSQL123
    5. Database Name: Leave it as default
    6. Server Group: Leave it as default

You should be connected to the localhost server now.

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 How to add Read More Read Less Button using JavaScript? #3 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #4 How to uninstall Cocoapods from the Mac OS? #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to Use SQL MAX() Function with Dates?

Recently Posted

#Dec 4 What is Etrieve Flow? #Dec 2 The unique operator($) in Envision Basic #Nov 25 Steps to Install Microsoft SQL Server on a MacOS #Nov 11 What is DevOps? #Nov 10 The * arithmetic operator in Envision Basic #Nov 10 What are Big Data Clusters in SQL Server?
You might also like these
What’s the difference between variables in CSS and SCSS (Sass)?CSSHow to apply style only to first child and/or only to children other than the first child?CSSKanban vs Scrum: The two frameworks of agile principlesMiscellaneousHow to create Flickering Texts using CSS?CSSDISTINCT ON: The confusing, unique and useful feature in PostgresPostgresCreate a responsive pricing table using simple HTML and CSSCSS