DEV Community

Cover image for Installing MS SQL Server on Mac (M1 Chip)
Avwerosuoghene Darhare-Igben
Avwerosuoghene Darhare-Igben

Posted on

Installing MS SQL Server on Mac (M1 Chip)

After struggling to install MS SQL Server on my Mac with M1 Chip , I discovered a solution that made the process easier. I want to share it with others who might be facing the same challenge. Let's make the developer's life a little bit simpler together.

Preparation

Before delving into the world of MS SQL Server on your trusty Mac, ensure you have Docker installed. Head to the official Docker website and download Docker Desktop for Mac with Apple silicon support at this link:

Image of the download page for docker desktop

Once the download is complete, install Docker Desktop on your M1 Mac.

How to install Docker on a Mac

MS SQL Server demands a significant amount of memory, prompting the need to expand your memory allocation. Ensuring sufficient resources will enable MS SQL to operate seamlessly, guaranteeing a smooth and efficient experience. Allocate approximately 6 GB of memory to Docker to provide ample resources for smooth performance in handling various tasks.

Image indicating the settings button

Image showing docker resource allocation

Now, with Docker standing tall, you're well-equipped for the forthcoming SQL Server adventure!

Downloading the SQL Server Image

Let's take the next step on our journey and fetch the SQL Server image for your Mac. Open your terminal and enter the following simple command:

docker pull mcr.microsoft.com/azure-sql-edge

If you face permission issues during the download, you may need to use sudo.

Sudo docker pull mcr.microsoft.com/azure-sql-edge

Once the image is downloaded, run the command below to set up the SQL Server container:

docker run -e "ACCEPT_EULA=1" -e "MSSQL_SA_PASSWORD=password" -e "MSSQL_PID=Developer" -e "MSSQL_USER=username" -p 1433:1433 -d --name=sql mcr.microsoft.com/azure-sql-edge

Let's understand the important parameters used in the command to set up the SQL Server container:

  • ACCEPT_EULA=1: This parameter signifies your acceptance of the End-User License Agreement, ensuring compliance and ethical usage of SQL Server in your coding endeavours.
  • MSSQL_SA_PASSWORD and MSSQL_USER: Here, you will select robust passwords and unique usernames to bolster the security and individuality of your developer identity.
  • --name=sql: By customising the name of the container as "sql," you establish a personal connection with the SQL Server, making the experience truly your own.

Remember to choose a strong and memorable password for MSSQL_SA_PASSWORD, and pick a unique username for MSSQL_USER. If you prefer a different SQL Server version, you can swap "mcr.microsoft.com/azure-sql-edge" with your desired version.
With this straightforward setup, you're well-prepared to continue your journey into the realm of MS SQL Server on your Mac!

Verifying and Troubleshooting

With your SQL Server container set up, let's ensure it's running smoothly and address any hiccups that may arise along the way.
To start your Docker container, simply run the command mentioned earlier. Now, to verify its successful deployment, execute the following command:

docker ps

This displays a list of running containers. Check if your SQL container is among them, ensuring that your setup is on the right track.
In case you can't find your container using the custom name you provided, fear not. Run the command below to see all containers on your system, including those not currently running

docker ps -a

Search for your SQL container in the list and investigate any potential errors that might have prevented it from running smoothly. Utilise the command below, replacing "container_id" with the actual ID of your SQL container:

docker logs container_id

Inspect the logs to identify any issues and resolve them efficiently.

Starting SQL Server

It's time to put your SQL Server into action! With just a simple command, you can ignite the power of your creation and begin your database adventure.
To start your SQL Server, open your terminal and run the following command:

mssql -u username -p password

Remember to replace "username" and "password" with the unique credentials you selected earlier.
Voilà! Your SQL Server instance is now up and running, ready to empower you in your data management and querying tasks.

GUI Interface

MS SQL GUI Interface

For a more user-friendly experience, consider using a GUI interface to interact with your SQL Server. All you need to do is download the Azure Data Studio and select the Apple Silicon installer for your M1 chip.

Download page for Azure Studio

Once the installation is complete, you can easily create and manage your databases according to your preferences.
Make sure to use the same username and password you set up when starting the SQL Server, ensuring a smooth and seamless connection. The Azure Data Studio provides a convenient and intuitive interface, simplifying the process of managing your databases.

Take advantage of this user-friendly tool to navigate through your database journey with ease. With the Azure Data Studio by your side, you can effortlessly unleash the full potential of your SQL Server setup!

Top comments (4)

Collapse
 
iamcymentho profile image
Odumosu Matthew

Couldn't have stumbled on this post at a better time. This has been helpful. Thanks for sharing!

Collapse
 
avwerosuoghene profile image
Avwerosuoghene Darhare-Igben

I'm thrilled to hear that you found the post helpful. If you have any questions or need further assistance, feel free to reach out. Happy coding!

Collapse
 
diogo_mota_f62d8267f6c70a profile image
Diogo Mota

"zsh: comando não encontrado: mssql" how can i fix this error in terminal?

Collapse
 
blessdarah profile image
Bless Darah Gah

Is there no way to use TablePlus to connect to the sqlserver instance?