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 Solution to the error “Visual Studio Code can’t be opened because Apple cannot check it for malicious software” #2 How to add Read More Read Less Button using JavaScript? #3 How to check if radio button is checked or not using JavaScript? #4 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #5 How to uninstall Cocoapods from the Mac OS? #6 PHP Login System using PDO Part 1: Create User Registration Page

Recently Posted

#Apr 8 JSON.stringify() in JavaScript #Apr 7 Middleware in NextJS #Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface
You might also like these
Can Firewall and IDPS Stop DDoS Attack?MiscellaneousIf statement shorthand examples in JavaScriptJavaScriptHow to add new elements with swing animation using JavaScript and CSS?CSSWordPress: How to access first and random row values from a repeater field in ACF?WordPressHow to create a simple digital clock using JavaScript?JavaScriptHow to use PHPMailer to send an Email via Gmail SMTP Server?PHP