MsSQL on MacOs

MSSql database is easy to configure on a Windows System . For MacOs we need to take care of few steps to get it installed and run properly .

Lets see what all steps we need to follow →

01 : Download Docker

Docker is a set of platform as …


This content originally appeared on DEV Community and was authored by Pranjal Sharma

MSSql database is easy to configure on a Windows System . For MacOs we need to take care of few steps to get it installed and run properly .

Lets see what all steps we need to follow →

01 : Download Docker

Docker is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. We would need it to run Microsoft SQL on Mac.

→ Check docker version
$ docker --version

→ Download and install docker from here 👉 Docker Desktop

02 : Download the MS SQL Server Image to Docker

→ After that, you need to pull the SQL Server 2019 Linux container image from Microsoft Container Registry.

[ Make sure docker is running in background ]

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

→ Then you can run the docker images command and verify whether the docker image has been pulled successfully.

03 : Run the docker container

→ Command to run the docker container.

🔥 Command to run the container 
docker run -d --name sql_server_demo -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=reallyStrongPwd123' -p 1433:1433 mcr.microsoft.com/mssql/server:2019-latest

🔥 Command for M1 Chip, please try this
docker run -e "ACCEPT_EULA=1" -e "MSSQL_SA_PASSWORD=reallyStrongPwd123" -e "MSSQL_PID=Developer" -e "MSSQL_USER=SA" -p 1433:1433 -d --name=sql mcr.microsoft.com/azure-sql-edge

→ Make sure to put you own password in SA_PASSWORD.
→ You can name your container after the --name flag.
→ -d flag represents the detach mode that releases the terminal after you run the above command.

→ Then run the docker ps command to verify whether your container has started to run

→ If your container stops after a few seconds it started, run docker ps -a command & > docker logs to check what’re the errors.

04 : Install the MS SQL CLI

→ Next, you need to install sql-cli via npm.

$ npm install -g sql-cli
OR
$ sudo npm install -g sql-cli

Link to install npm if not present .

05 : Test the Installation by Login In

→ Testing the mssql integration by logging in

$ mssql -u sa -p <Your Pass word>

→ If correctly done : mssql> prompt will come up.

→ Then run select @@version to verify the connectivity.

$ mssql -u sa -p reallyStrongPwd123
Connecting to localhost...done
sql-cli version 0.6.2
Enter ".help" for usage hints.
mssql> select @@version
--------------------------------------------------------------------
Microsoft SQL Server 2019 (RTM-CU15) (KB5008996) - 15.0.4198.2 (X64)
Jan 12 2022 22:30:08
Copyright (C) 2019 Microsoft Corporation
Developer Edition (64-bit) on Linux (Ubuntu 20.04.3 LTS) <X64>
1 row(s) returned
Executed in 1 ms
mssql>

06 : [OPTIONAL] Download and install the GUI application - Azure Data Studio

Azure Data Studio

07 : 😊 We Are Done ! Stop the services once completed with the work

docker stop <container-id> to stop the docker container.


This content originally appeared on DEV Community and was authored by Pranjal Sharma


Print Share Comment Cite Upload Translate Updates
APA

Pranjal Sharma | Sciencx (2024-06-20T17:08:24+00:00) MsSQL on MacOs. Retrieved from https://www.scien.cx/2024/06/20/mssql-on-macos/

MLA
" » MsSQL on MacOs." Pranjal Sharma | Sciencx - Thursday June 20, 2024, https://www.scien.cx/2024/06/20/mssql-on-macos/
HARVARD
Pranjal Sharma | Sciencx Thursday June 20, 2024 » MsSQL on MacOs., viewed ,<https://www.scien.cx/2024/06/20/mssql-on-macos/>
VANCOUVER
Pranjal Sharma | Sciencx - » MsSQL on MacOs. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/06/20/mssql-on-macos/
CHICAGO
" » MsSQL on MacOs." Pranjal Sharma | Sciencx - Accessed . https://www.scien.cx/2024/06/20/mssql-on-macos/
IEEE
" » MsSQL on MacOs." Pranjal Sharma | Sciencx [Online]. Available: https://www.scien.cx/2024/06/20/mssql-on-macos/. [Accessed: ]
rf:citation
» MsSQL on MacOs | Pranjal Sharma | Sciencx | https://www.scien.cx/2024/06/20/mssql-on-macos/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.