Open In App

How to Install SQL Server on MacOS?

In this article, we are going to learn “How to install SQL Server Express in MacOs”. Now, before we jump to the setup part, Let’s learn about SQL Server Express. So, SQL Server Express is an open-source RDBMS database management system i.e. Relational database management system which is used to store, update, and access the data stored in different relational databases. It provides many benefits such as scalability, security, and business intelligence.

Steps to Install SQL Server in MacOS

To install SQL Server Express for your Mac, you need to follow the steps given below:-



Step 1: Installing Docker For Mac

Step 2: Installing SQL Server 2022



Step 3: Connecting to SQL Server

1. Installing Docker For Mac

Now, The first step is to download and install the Docker desktop setup for your Mac. Your system must have at least 4GB RAM and a supported version of macOS. You can download Docker manually using the Docker Application or from the command line. So, first I will show how to install it from the application and then from CLI. You can choose either way.

a. Install from Application Setup

Install Docker Desktop on Mac

Docker File Installation in Mac

b. Install from Command line Interface (CLI)

sudo hdiutil attach Docker.dmg
sudo /Volumes/Docker/Docker.app/Contents/MacOS/install
sudo hdiutil detach /Volumes/Docker

2. Installing SQL Server 2022

Now, Install the SQL Server 2022 for docker containers, to use SQL Server on MacOs. You just need to follow the steps given below in your command line (CLI).

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

Install SQL Server

docker run -d --name SQL_Server_Docker -e 'ACCEPT_EULA=Y' -e DB_Password' -p 1433:1433 mcr.microsoft.com/mssql/server:2022-latest 

The above command contains certain parameters, which are defined as,

-d : It is used to launch your Docker container in daemon mode i.e. it runs on background having terminal window off. It is an Optional Parameter, If you want run Docker with its terminal window open you can leave this.

–name : It provides name to your Docker Container. This is also Optional Parameter. e.g. name is SQL_SERVER_DOCKER

-e ‘ACCEPT_EULA=Y’ : It shows that you agrees with the Docker EULA (End User License Agreement) and It is a required Parameter.

-e ‘SA_PASSWORD=DB_Password’ : It is a required Parameter that is used to set password for your database. In the above example, the database password is DB_Password.

-p 1433:1433 : It is a default port to listen connections and it is used to map your Docker container to your local port 1433.

mcr.microsoft.com/mssql/server:2022-latest : It is used to show which image to use in Docker Container.

docker ps -a

3. Connecting to SQL Server

In order to connect to the SQL Server from Terminal or command Line of your MacOs , you need to follow the steps given below :-

sudo npm install -g sql-cli
mssql -u sa -p DB_Password

The command consists certain parameters described as :-

-u: It is used to specify the username to connect with your database. In above example, we have used “sa” as database username.

-p: It defines the database password. In above example, we have used “DB_Password” as database password.

Finally, After successfully connecting with your SQL Server you will seen a message response as given below:

Output:

Connecting to localhost…done

sql-cli version 0.6.2

Enter “.help” for usage hints.

mssql

Now, you have successfully install and connected to SQL Server express in your Mac system.

Conclusion

In this article, You have successfully setup and installed SQL Server express in your Mac system. Now, we can use SQL Server Express for development or learning process and it is also suitable for creating small-scale applications. If you face any problem while installing just re-evaluate and make sure you have followed each and every step as described above. You can checkout more about SQL Server Express here.

Article Tags :