SQL Server Management Studio (SSMS) is a free integrated tool that allows you to access, configure, manage and administer all components of the SQL server, Azure SQL Database, Azure SQL Managed Instance and Azure Synapse Analytics.
Generally, SSMS only runs on Windows, but there are two ways you can install it on Mac.
The first way is to install a virtual machine (VM) using programs like VirtualBox, Parallels Desktop, etc. Then you’ll install Windows onto that VM, which requires a payment for the license, and finally, you’ll use the VM to install SSMS.
The second option is to install the SQL server using Docker. Microsoft provides Azure Data Studio as a graphical user interface to run the SQL server on Mac. This article covers the second option.
Docker is a tool designed to make the creation, deployment, and running of applications by using containers much easier. Below are the following steps to run SSMS on Mac.
Download docker on Mac. Then you’ll select whether to download it to a Mac with an Intel chip or an Apple chip. In this example, we have used an Intel chip, hence the downloaded intel docker “.dmg” file.
Once you’ve downloaded the “.dmg” file on your Mac, you can drag and drop it into your applications folder.
Then open the docker application.
By default, docker allocates 2 GB of memory, and an SQL server needs 3.25 GB to run, so we need to increase the memory to 4 GB in Docker. To do that, go to settings, then preferences, then select the “Resources” screen and slide the memory slider up to at least 4 GB. Click “Apply & Restart.”
Open the terminal in the Mac and run the following code. This will install the 2022 MS SQL Server image on your device.sudo docker pull mcr.microsoft.com/mssql/server:2022-latest
Once we run the above command, Docker will start extracting the image from the web and downloading the same into your local machine. The Docker image will become visible in the docket desktop window, as shown in the below image.
Run the following command in the terminal again to launch the image that was downloaded in Docker:docker run -d --name sql_server_test -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=reallyStrongPwd123' -p 1433:1433 mcr.microsoft.com/mssql/server:2022-latest
Once the above command runs successfully, go to Docker desktop and select the container option. Then look for the container “sql_server_test” as we mentioned in the above command.
From the above we can see the container “sql_server_test” is running.
We need to install sql-cli via npm. Before proceeding, npm should be installed on the Mac. If not, download npm now.
Run the below command on your terminal. $ npm install -g sql-cli
If you get permission error, use the command below:$ sudo npm install -g sql-cli
Once you’ve installed the sql-cli, test it by logging in using the command below:$ mssql -u sa -p
After giving my password, here is the command:$ mssql -u sa - p dockerStrongPwd123
Then run select @@version
to verify the connectivity in the terminal.
If you get the above message, congratulations — the SQL server is up and running on your Mac. You can now go ahead and run SQL queries against the SQL server.
We need to install a graphical user interface (GUI). For that, we’ll download Azure Data Studio. Azure Data Studio is available on Mac as well as on Windows because SSMS won’t work on Mac.
From the above link you will be able to download the zip file. Unzip and open the Azure Data Studio. Once you’ve done so, select a new connection and give it the below credentials.
Then click connect. We have to enter the username and password that we used in step five.
As soon as you get the connectivity via the Azure Data Studio, you can run your SQL queries and get your work done.
Once you complete your work, you can save your progress and quit the workspace. Enter the mssql prompt [press ctrl+c]
and stop the running Docker container using the docker stop
command. If you want to re-open it, restart the existing docker container and start the SQL server via the terminal giving your username and password.$ mssql -u sa -p dockerStrongPwd123
Then open Azure Data Studio once again and continue your work.
Built In’s expert contributor network publishes thoughtful, solutions-oriented stories written by innovative tech professionals. It is the tech industry’s definitive destination for sharing compelling, first-person accounts of problem-solving on the road to innovation.