How to Install SQL Server

SQL Server used to be available on Windows machines only. If you didn’t have Windows, you didn’t install SQL Server.

Now, SQL Server is available on Windows, Linux, and even Mac (via Docker containers).

This obviously means that an article titled “how to install SQL Server” is not as simple as it used to be!

Therefore, in this article I present a quick, high-level overview of installing SQL Server across each operating system, then link to a more detailed article for each platform.

If you prefer to read the full in-depth tutorial for your specific platform, see:

The following article combines the information in those articles into a more condensed version, as well as providing some extra information regarding containers, virtual machines, and running multiple instances of SQL Server on the same machine.

Install SQL Server on Windows

First thing to do when installing on Windows is to decide whether to use the installation wizard, or some other method.

The installation wizard is usually the best method for those who are new to SQL Server, or who don’t have any specific installation requirements.

Installation Wizard

To install SQL Server using the installation wizard, simply download the setup file from Microsoft’s SQL Server Downloads page, open that file, and follow the prompts.

If you prefer step-by-step instructions (including screenshots), see How to Install SQL Server on Windows.

Here are the basic steps outlined in that article:

  1. Download the setup file from Microsoft’s SQL Server Downloads page. You will need to choose the edition you require. If you’re a developer, the Developer edition is a full-featured free edition, licensed for use as a development and test database in a non-production environment.
  2. Once you’ve initiated the download, you should see the set up file being downloaded to your computer at the bottom of your browser. Once it has downloaded, click Open file to launch the installation wizard.
  3. If you get a prompt asking if you’d like this app to make changes to your device, click Yes.
  4. You will now be prompted to choose an installation type (Basic, Custom, or Download Media). If you’re happy with a default installation, click Basic to install the SQL Server Database Engine with the default configuration. Otherwise select your preferred option. Whichever option you choose will obviously change the next steps. The following steps occur after selecting the Basic option.
  5. The license terms appear. If you accept the terms, click Accept.
  6. You’ll now be shown the install location, and you’ll have the option to change it. Unless you have reason to change the location, click Install.

That last step triggers the installation. You will now see the installation progress flashing across the screen. First it downloads the install package, then it extracts the setup files and actually installs SQL Server. It does all this automatically – no need for you to click any further buttons.

That’s all there is to installing SQL Server on Windows using the installation wizard.

Connect to SQL Server on Windows

SQL Server used to be shipped with SQL Server Management Studio (SSMS), which is a graphical tool for administering SQL Server.

These days, SSMS is no longer shipped with SQL Server. You need to download and install SSMS separately if you want to use it.

See How to Install SSMS for step by step instructions for installing it, including screenshots.

Another nice GUI for administering SQL Server is Azure Data Studio. As from SSMS 18.7, when you install SSMS, it automatically installs Azure Data Studio alongside it.

Other Methods for Installing SQL Server on Windows

Microsoft also provides various other ways to install SQL Server onto a Windows machine.

Check out the following articles on the Microsoft website for further details on each method:

Using the command prompt enables you to create a script before hand that specifies the features to install and how they should be configured. Once the script has been written, it’s just a simple matter of running it.

The configuration file option enables you to deploy SQL Server throughout the enterprise with the same configuration.

Install SQL Server on Linux

You can install on Ubuntu, Red Hat (RHEL), and SUSE.

Below are instructions for installing SQL Server on each of these distributions.

Install SQL Server on Ubuntu

The following steps are what I used to install SQL Server 2019 for Linux on Ubuntu 18.04.

Import the public repository GPG keys:

wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -

Register the repository:

sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/18.04/mssql-server-2019.list)"

Install SQL Server:

sudo apt-get update
sudo apt-get install -y mssql-server

Run setup and follow the prompts:

sudo /opt/mssql/bin/mssql-conf setup

Verify that the service is up and running:

systemctl status mssql-server --no-pager

Assuming that comes back fine, SQL Server is now installed on your Ubuntu machine.

See How to Install sqlcmd & bcp on Ubuntu for an example of connecting to SQL Server and running a query.

See How to Install Azure Data Studio on Ubuntu for a GUI option.

Also see How to Install SQL Server on Ubuntu 18.04 for a more detailed article that combines both the installation, and the installation of the DB utilities.

Install SQL Server on Red Hat (RHEL)

The following steps are what I used to install SQL Server 2019 for Linux on RHEL 8.3.

SQL Server requires Python 2 and OpenSSL 1.0, which isn’t included in RHEL 8.

To install python2 and openssl10, open terminal and run the following commands:

sudo yum install python2
sudo yum install compat-openssl10

The following code configures python2 as the default interpreter:

sudo alternatives --config python

If you see a list of options, choose the number that corresponds to python2.

Now you can go ahead and download the Microsoft SQL Server 2019 Red Hat repository configuration file:

sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/8/mssql-server-2019.repo

Note: If you’re installing on to RHEL 7, change the path from /rhel/8/ to /rhel/7/.

Install SQL Server:

sudo yum install -y mssql-server

Once it’s installed, run mssql-conf setup:

sudo /opt/mssql/bin/mssql-conf setup

Follow the prompts to choose your edition, accept the license agreement, and set the sa password.

You can run the following command to verify that SQL Server is running:

systemctl status mssql-server

See How to Install sqlcmd & bcp on Red Hat for an example of connecting to SQL Server and running a query.

See How to Install Azure Data Studio on Red Hat for a GUI option.

Also see How to Install SQL Server on Red Hat 8 for a more detailed article on both installing SQL Server and connecting to it.

Install SQL Server on SUSE

The following steps install SQL Server 2019 for Linux on SUSE 12.

Download the Microsoft SQL Server 2019 SLES repository configuration file:

sudo zypper addrepo -fc https://packages.microsoft.com/config/sles/12/mssql-server-2019.repo

Refresh your repositories:

sudo zypper --gpg-auto-import-keys refresh

To ensure that the Microsoft package signing key is installed on your system, use the following command:

sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc

Install SQL Server:

sudo zypper install -y mssql-server

Run mssql-conf setup:

sudo /opt/mssql/bin/mssql-conf setup

Follow the prompts to choose your edition, accept the license agreement, and set the sa password.

You can run the following command to verify that SQL Server is running:

systemctl status mssql-server

See How to Install sqlcmd & bcp on SUSE for an example of connecting to SQL Server and running a query.

Also see How to Install SQL Server on SUSE 12 for a more detailed article that combines installing SQL Server as well as the above utilities.

Install SQL Server on MacOS

Installing SQL Server on a Mac is similar to installing it on Linux, in that you can simply run a few commands from Terminal.

The main difference is that, on a Mac, you need to install Docker first. This is because SQL Server runs inside a Docker container on the Mac.

Fortunately, installing Docker is very straightforward, and only takes a few minutes.

Below are the steps involved in installing SQL Server on a Mac.

Install Docker

If you don’t have it already, download Docker from the Docker website and follow the instructions to install it.

Then launch Docker from the Applications folder. Once launched, you should see the little Docker icon in the top menu bar of your Mac.

SQL Server requires a minimum of 2GB memory. You’ll probably find that this is the amount that is automatically allocated to Docker upon installation. However, you can also (optionally) increase the memory assigned to Docker by clicking the Docker icon in the top menu bar of your Mac, selecting Preferences, then Resources > Advanced. You should see a slider that enables you to adjust the memory. I normally increase it to 4GB.

If you prefer screenshots, see How to Install SQL Server on a Mac. That article provides screenshots of Docker, as well as the following steps for installing SQL Server.

Install SQL Server

With Docker up and running, now you can go ahead and install SQL Server.

Open a Terminal, and run the following commands.

Pull the latest Docker container image for SQL Server:

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

At the time this article was written, SQL Server 2019 was the latest edition. Feel free to check for the latest container version on the Docker website.

Launch an instance of that Docker image:

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

Change the details as required. For example, change the password to your own strong password.

Also change sql_server_demo to a name of your choosing. That’s the name for the container. This can be handy when stopping and starting your container from the Terminal.

That’s all there is to installing SQL Server on a MacOS system.

Check the Installation

You can check that the Docker container is running by entering the following command into Terminal:

docker ps

This should return something that looks like this:

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4e4aa21eb391 mcr.microsoft.com/mssql/server:2019-latest "/opt/mssql/bin/sqls…" 23 seconds ago Up 21 seconds 0.0.0.0:1433->1433/tcp sql_server_demo

Connect to SQL Server

You can connect to SQL Server by using the sqlcmd utility that is helpfully located inside the container.

First, run the following command:

sudo docker exec -it Bart "bash"

Then this one (using your own password of course):

/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "reallyStrongPwd123"

This should bring you to the sqlcmd prompt 1>.

You can now go ahead and create databases, run T-SQL queries, etc.

See How to Install Azure Data Studio on a Mac for a GUI option.

Install SQL Server using Containers

The above example uses a Docker container to install SQL Server on to a Mac.

But the container option isn’t limited to just Macs. You can also run SQL Server container images on Windows and Linux machines.

In addition to this, you have to option of using Podman instead of Docker.

Podman provides a CLI similar to Docker container Engine. You should be able to alias Docker to Podman (alias docker=podman) without any problems.

At the time of writing, Podman runs only on Linux platforms, however a REST API and clients are currently under development which will allow Mac and Windows platforms to call the service.

Install SQL Server via a Virtual Machine

Another option for installing SQL Server is to use a virtual machine.

A virtual machine enables you to install a completely different operating system on your computer, even if your computer wouldn’t normally support that operating system.

For example, you can use a virtual machine to run Windows on a Mac. Or you could run Linux on a Windows machine. Or MacOS on Windows, and so on.

See How to Install SQL Server on a Mac running VirtualBox for detailed instructions and screenshots.

Install Multiple Versions of SQL Server Side by Side

It’s possible to install multiple instances of SQL Server on the same machine. For example, you could have an instance of SQL Server 2017 and an instance of SQL Server 2019 running simultaneously.

Bear in mind that some components are shared across multiple instances.

Some components are shared only across minor versions, while others are shared across major versions. If the shared components are selected during upgrade, the existing components are upgraded to the latest version.

But some components are shared by all instances of all installed versions of SQL Server. When you install different versions of SQL Server side by side on the same machine, these components are automatically upgraded to the latest version.

Also, multiple instance could cause issues for things like performance tuning, patching schedules, security, etc

Whether or not this works for you depends on your situation. It might be perfect for your development environment, but perhaps not so great for your production environment.

Virtual Machines

The above issues don’t apply when you install each instance in its own virtual machine. In that case, it is basically self-contained within its own environment.

Containers

The same is true for containers. You can use containers to run multiple versions of SQL Server simultaneously.

To do this, simply follow the same installation process for each container.

The main difference is that you’ll need to make sure they both don’t try to use the same TCP port (the TCP port that the containers are mapped to on the host machine). So you’ll need to change the TCP port number on your second installation.

See How to Run SQL Server 2017 and 2019 Simultaneously on a Mac for an example of doing this.