How to Install SQL Server on an M1 Mac (ARM64)

I previously explained how to install SQL Server on a Mac using the SQL Server for Linux Docker image.

Since then, Apple has released its M1 chip, which uses ARM architecture. This can cause a problem when trying to install SQL Server. The problem is, at the time of writing, SQL Server isn’t supported on the ARM architecture.

Fortunately, there’s an alternative.

The container image for Azure SQL Edge can be installed on the M1 Mac. Therefore, we can use that image instead of the SQL Server image.

Azure SQL Edge is an optimized relational database engine geared for IoT and IoT Edge deployments. It’s built on the latest versions of the SQL Server Database Engine, so you can use T-SQL code just like you would when using SQL Server. You can also the same tools to query Azure SQL Edge that you would use with SQL Server (such as SSMS, Azure Data Studio, etc).

In this article I install the Developer Edition of Azure SQL Edge on a Mac with the M1 chip.

Install Docker

Seeing as we’re installing SQL Edge via a Docker container, we need to have Docker installed.

If you don’t already have Docker, download and install it, as follows:

  1. Download Docker from the Docker website. Be sure to download the one for the M1 Mac (the button was called Mac with Apple Chip when I downloaded it).
  2. Once downloaded, open the .dmg file and drag the Docker.app icon to your Applications folder as instructed.
  3. Launch Docker the same way you’d launch any other application (eg, via the Applications folder, the Launchpad, etc). When you open Docker, you might be prompted for your password. Go ahead and provide your password, as Docker needs this to run.

Install Azure SQL Edge

Now that Docker is installed, we can go ahead and install Azure SQL Edge. As mentioned, this uses the SQL Server Database Engine, and we can therefore use it to run T-SQL queries, etc, as if we were querying SQL Server.

Open a Terminal window and run the following command:

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

That pulls/downloads the container image to your local machine.

You can alternatively check the container options on the Docker website if you prefer.

Once the download is completed, run the following command to launch an instance of the Docker image you just downloaded:

sudo docker run --cap-add SYS_PTRACE -e 'ACCEPT_EULA=1' -e 'MSSQL_SA_PASSWORD=bigStrongPwd' -p 1433:1433 --name sqledge -d mcr.microsoft.com/azure-sql-edge

Be sure to change bigStrongPwd to a strong password of your choice. You can also change the value of the --name parameter if you wish.

By default, the container is run with the Developer Edition. You can run the Premium Edition by adding -e 'MSSQL_PID=Premium'.

Check the Docker Container

We can use the following command to check whether the container is up and running:

docker ps

Result:

a190dd199b17   mcr.microsoft.com/azure-sql-edge   "/opt/mssql/bin/perm…"   10 seconds ago   Up 9 seconds   1401/tcp, 0.0.0.0:1433->1433/tcp   sqledge

This shows me that the container is in fact, up and running.

If, for some reason your container isn’t up and running, try the following command:

docker start sqledge

Replace sqledge with the name of your container.

With the container up and running, we can now go ahead and connect to SQL Edge.

Connect to SQL Edge

You can now connect to your Azure SQL Edge installation by using the details provided when launching the Docker image.

Here’s a screenshot of connecting to Azure SQL Edge via Azure Data Studio:

Screenshot of connecting to Azure SQL Edge via Azure Data Studio

Here’s how to install Azure Data Studio on a Mac.

Microsoft states that Azure Data Studio “currently does not support the ARM architecture” but I had no problem with installing it on my M1 Mac (i.e. with ARM architecture).

Run SQL Queries

Once connected to SQL Edge, you can create databases, run T-SQL queries, etc (T-SQL is SQL Server’s extension to SQL).

See my SQL tutorial to get up to speed with running SQL queries.

Supported Features in SQL Edge

I should mention that some SQL Server features are unsupported in SQL Edge. Azure SQL Edge supports a subset of the features supported SQL Server 2019 on Linux.

That said, SQL Edge does have some features that are unavailable in SQL Server (such as the DATE_BUCKET() function).

See Supported features of Azure SQL Edge on the Microsoft website for a full breakdown.