How to install SQL Server on macOS

macOS is one of the most popular operating systems in the world, with a loyal following, second only to Microsoft Windows—in terms of numbers, that is. And if we talk user-friendliness, performance, reliability, and the sheer breadth of capabilities, it might as well be second to none. So, it is no wonder that macOS is quite widely used for database development—and, taken together with Microsoft SQL Server, which is the world's biggest proprietary relational DBMS, they make a powerful combo.

On this page, you will learn how to get this combo to work—how to install SQL Server 2022 on macOS via Docker, how to establish a connection, and how to proceed to actual database development and management most quickly and easily.

How to install and set up SQL Server on macOS

First, let's list the prerequisites for installation:

  • A Mac running macOS 11 Big Sur or later
  • A user with administrator-level privileges
  • Access to Terminal

1 - Install Docker Desktop

1. Go to the official download page and download the Docker Desktop file. Depending on the Mac you are using (either with an Intel chip or with an Apple Silicon), click the respective link to start the download.

Install Docker Desktop

2. Double-click the downloaded .dmg file to begin the installation and drag-and-drop the Docker application icon to your Applications folder.

That's it! Now you can get down to installing SQL Server on your Mac.

2 - Install SQL Server 2022

1. In Terminal, enter and run the following command.

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

If Terminal prompts you to enter the password to your Mac, do so. Eventually, the completed download will look similar to the following.

Install SQL Server 2022

2. After the download is complete, enter and run the following command.

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

This command consists of the parameters:

-d — launches your Docker container name in the daemon mode, enabling it to run in the background, without the need to keep your Terminal window open.

--name — specifies the name for your Docker container. In our example, the name is SQL_Server_Docker.

-e 'ACCEPT_EULA=Y' — confirms that you accept the Docker EULA (End User License Agreement).

-e 'SA_PASSWORD=DB_Password' — sets your database password. In our example, the password is DB_Password.

-p 1433:1433 — maps your Docker container to the local port 1433.

-p 1433:1433 — selects an image file for Docker to use.

After it's done, SQL Server should be running on your Mac. To make sure, you can check the status of your SQL Server Docker container with the following command.

docker ps -a

Now check the output. If the STATUS column says Up, your Docker container is running properly. If it says Exited, something has gone wrong, and your container is not running.

3 - Connect to SQL Server from Terminal

To connect to your newly installed SQL Server from Terminal, you will first need to install a command-line tool sql-cli by running the following command.

sudo npm install -g sql-cli

This command-line tool will enable you to run commands and queries for your SQL Server instance directly in Terminal. Note that to make this work, you need to have Node.js installed on your Mac; if you don't have Node.js, download and install it. The installation of Node.js will additionally install npm, which is used in the command above.

Once sql-cli is installed, you can connect to your SQL Server with the following command.

mssql -u sa -p DB_Password

This command consists of the following:

-u — specifies the username to connect to your database. In our example, we use the default username sa.

-p — specifies the database password. In our case, we have specified DB_Password, the one we set during the launch of our Docker container.

You will get a message similar to the following.

Connecting to localhost...done
sql-cli version 0.6.2
Enter ".help" for usage hints.
mssql

And this will mean that you have successfully connected to your SQL Server.

How to install dbForge Studio for SQL Server on a Mac via CrossOver

This is where things become really interesting. After all, the installation and setup of SQL Server is a fleeting moment—and afterwards, you need to find a proper set of tools that will help you interact with your databases. We've got one for you — dbForge Studio for SQL Server — an IDE that is designed to cover the majority of possible tasks related to the development, management, and administration of SQL Server databases. Add here the intuitive user interface of the Studio, and you get yourself a toolset that will make your routine work with databases a pleasure.

The one possible drawback of the Studio is that it isn't native to macOS—it requires an additional compatibility solution called CodeWeavers CrossOver, which helps it run on your Mac seamlessly. But even with that solution, the installation will not take too long. Let's see how it's done.

1 - Download the CrossOver Mac installation

Go to the official download page and download the CrossOver Mac installation archive. You can start with a 14-day free trial offered by CodeWeavers.

Download the CrossOver Mac installation

2. Extract the installation and launch it

Extract the installation file from the archive. Double-click the file, click Open to launch it, and then agree to move it to your Applications folder. After CrossOver is installed, launch it.

3. Install .NET Framework 4.7.2 package

First of all, you need to install the prerequisite software—namely, the .NET Framework 4.7.2 package. Start entering "Microsoft .NET Framework 4.7.2" in the search box, and then click Microsoft .NET Framework 4.7.2 in the results.

Extract the installation and launch it

Once you're on the dedicated page of .NET Framework 4.7.2, click Install.

Continue installation .NET Framework 4.7.2 package

4. Select a bottle to use for this installation

CrossOver will ask you to select a bottle for the .NET Framework package to be installed into. A bottle is a container where an application—in our case, dbForge Studio—is installed along with the environment that it requires to run properly. That said, click Select a Bottle to create a new bottle, specify the bottle name and make sure you set the bottle type to Windows 10 64-bit. After that, click Done.

Select a bottle to use for this installation

After the installation of the .NET Framework package begins, you'll need to agree to the license terms and repeatedly reboot the bottle environment by clicking Restart Now when prompted (note that these reboots will not restart your machine). After the last component—.NET Framework 4.7.2—is installed, you will get a corresponding message. Now the environment in your bottle is ready—click Finish and proceed to install dbForge Studio for SQL Server.

Complete installation

5. Install Studio into Bottle

First, you need to download the dbForge Studio installer file and place it in a folder of your choice. Then go back to CrossOver, find the bottle you've just created and click Install Application into Bottle under Bottle Actions.

Install Application into Bottle

On the Install a Windows Application page, click Install an unlisted application.

Install a Windows Application

On the Unlisted Application page, click Install.

Unlisted Application

5-1. Choose installer

This is where you need to specify the location of the previously downloaded dbForge Studio installer file. Once it's done, click Choose installer.

Choose installer

5-2. Go through Studio's installation wizard

The dbForge Studio installation wizard opens. Click Install.

dbForge Studio installation

On the Select Destination page, select the folder for the Studio to be installed into and click Next.

Select Destination

On the File Associations page, you can keep all the selected settings unchanged and simply click Next.

File Associations

On the Startup Optimization page, select the option you prefer and click Next. Note that if you select to generate images, the installation will require a bit of extra time, but the application launch will commence faster in the future.

Startup Optimization

Once the installation is complete, click Finish. Note that the Launch dbForge Studio for SQL Server checkbox should be cleared in order to allow CrossOver to finalize the installation properly.

Finish the installation

6. Turn on High Resolution Mode

Finally, CrossOver will inform you about the success of your installation, and you'll see that dbForge Studio is shown in the bottle. We also recommend activating the High Resolution Mode with the corresponding toggle and rebooting the bottle afterwards. This will make your experience with the Studio smoother and more convenient.

High Resolution Mode

How to remotely connect to SQL Server running on macOS

Now that the dbForge Studio is installed and ready for work, you might as well start with connecting to your SQL Server, which is just a matter of moments.

Note
In order to enable remote access to your SQL Server, the machine hosting it must be connected under a public IP address, which can be delivered by your Internet provider. If you have a public IP address and the remote connection still fails, you may need to set up port forwarding from your router to the server (the instructions may be found in the manual of the router model you are using).

1. Launch dbForge Studio in CrossOver

Launch the Studio in CrossOver, go to the Database menu and click New Connection.


2. Database Connection Properties

Now all you have to do is configure your connection parameters: specify the server name, authentication method, login, password, and the database you are going to work with. Optionally, you can click Test Connection to check whether everything's all right. Or you can just click Connect, and that will be it.

How to uninstall SQL Server on macOS

The uninstallation of your SQL Server container from Docker on macOS is a very easy operation that is also executed via Terminal. The following example shows how we can remove our abovementioned container - SQL_Server_Docker.

docker stop SQL_Server_Docker
docker rm SQL_Server_Docker

Please note that the removal of a container is an irreversible operation, so, if necessary, be sure to back up your databases and the data contained within before executing this command.

Conclusion

This is how you can set up your work with SQL Server databases on a Mac from scratch. Probably the most important thing here is to choose the toolset that will empower you to handle nearly any operation with your databases and actual data. That's why we invite you to download dbForge Studio for SQL Server for a FREE 30-day trial. Explore its rich capabilities yourself—and your productivity and effectiveness will reach an all-time high from day one.