Configure repositories for installing and upgrading SQL Server on Linux

Applies to: SQL Server - Linux

This article describes how to configure the correct repository for SQL Server 2017 (14.x) and SQL Server 2019 (15.x) installations and upgrades on Linux. At the top, your current selection is Red Hat (RHEL).

This article describes how to configure the correct repository for SQL Server 2017 (14.x) and SQL Server 2019 (15.x) installations and upgrades on Linux. At the top, your current selection is SUSE (SLES).

This article describes how to configure the correct repository for SQL Server 2017 (14.x) and SQL Server 2019 (15.x) installations and upgrades on Linux. At the top, your current selection is Ubuntu.

Tip

SQL Server 2022 (16.x) is now available! To try it, use this article to configure the mssql-server-2022 repository. Then install using the instructions in the installation guide.

Repositories

When you install SQL Server on Linux, you must configure a Microsoft repository. This repository is used to acquire the database engine package, mssql-server, and related SQL Server packages. There are currently three main repositories:

Repository Name Description
2022 mssql-server-2022 SQL Server 2022 (16.x) repository.
2019 mssql-server-2019 SQL Server 2019 (15.x) Cumulative Update (CU) repository.
2017 mssql-server-2017 SQL Server 2017 (14.x) Cumulative Update (CU) repository.

The Cumulative Update (CU) repository contains packages for the base SQL Server release, and any bug fixes or improvements since that release. Cumulative updates are specific to a release version, such as SQL Server 2019 (15.x). They are released on a regular cadence. GDR updates are released in the same CU repository.

Each release contains the full SQL Server package and all previous updates for that repository. You can also downgrade to any release within your major version (for example, 2019).

Configure repositories

Use the steps in the following sections to configure repositories on Red Hat Enterprise Server (RHEL).

Use the steps in the following sections to configure repositories on SUSE Linux Enterprise Server (SLES).

Use the steps in the following sections to configure repositories on Ubuntu.

Check for previously configured repositories

First verify whether you have already registered a SQL Server repository.

  1. View the files in the /etc/yum.repos.d directory with the following command:

    sudo ls /etc/yum.repos.d
    
  2. Look for a file that configures the SQL Server directory, such as mssql-server.repo.

  3. Display the contents of the file using cat.

    sudo cat /etc/yum.repos.d/mssql-server.repo
    
  4. The name property is the configured repository. You can identify it with the table in the Repositories section of this article.

First verify whether you have already registered a SQL Server repository.

  1. Use zypper info to get information about any previously configured repository.

    sudo zypper info mssql-server
    
  2. The Repository property is the configured repository. You can identify it with the table in the Repositories section of this article.

First verify whether you have already registered a SQL Server repository.

  1. View the contents of the /etc/apt/sources.list file.

    sudo cat /etc/apt/sources.list
    
  2. Examine the package URL for mssql-server. You can identify it with the table in the Repositories section of this article.

Remove old repository

If necessary, remove the old repository with the following command.

sudo rm -rf /etc/yum.repos.d/mssql-server.repo

This command assumes that the file identified in the previous section was named mssql-server.repo.

If necessary, remove the old repository. Use one of the following commands based on the type of previously configured repository.

Repository Command to remove
2022 sudo zypper removerepo 'packages-microsoft-com-mssql-server-2022'
2019 CU sudo zypper removerepo 'packages-microsoft-com-mssql-server-2019'
2017 CU sudo zypper removerepo 'packages-microsoft-com-mssql-server-2017'

If necessary, remove the old repository. Use one of the following commands based on the type of previously configured repository.

Note

  • Starting with SQL Server 2019 (15.x) CU10, Ubuntu 20.04 is supported.
  • Starting with SQL Server 2019 (15.x) CU3 and SQL Server 2017 (14.x) CU20, Ubuntu 18.04 is supported.
  • If you use Ubuntu 18.04, change the path below to /ubuntu/18.04 instead of /ubuntu/20.04, and use the correct distribution code name.
Repository Command to remove
2022 sudo add-apt-repository -r 'deb [arch=amd64] https://packages.microsoft.com/ubuntu/22.04/mssql-server-2022 jammy main'
2019 CU sudo add-apt-repository -r 'deb [arch=amd64] https://packages.microsoft.com/ubuntu/20.04/mssql-server-2019 focal main'
2017 CU sudo add-apt-repository -r 'deb [arch=amd64] https://packages.microsoft.com/ubuntu/18.04/mssql-server-2017 bionic main'

Configure new repository

Configure the new repository to use for SQL Server installations and upgrades. Use one of the following commands to configure the repository of your choice.

Note

The following commands for SQL Server 2019 (15.x) points to the RHEL 8 repository. RHEL 8 doesn't come preinstalled with python2, which is required by SQL Server. For more information, see Installing Microsoft SQL Server on Red Hat Enterprise Linux 8 Beta.

  • Starting with SQL Server 2022 (16.x) CU 10, RHEL 9 is supported.
  • Starting with SQL Server 2017 (14.x) CU 20, RHEL 8 is supported.

Depending on the version of RHEL you use, ensure the paths match /rhel/8, or /rhel/9. Our packages are agnostic to RHEL minor versions. This means that if you use RHEL 8.7, you'll need to use the path /rhel/8 to configure your repository.

Repository Version Command
2022 2022 sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/9/mssql-server-2022.repo
2019 CU 2019 sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/8/mssql-server-2019.repo
2017 CU 2017 sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/8/mssql-server-2017.repo

Configure the new repository to use for SQL Server installations and upgrades. Use one of the following commands to configure the repository of your choice.

Repository Version Command
2022 2022 sudo zypper addrepo -fc https://packages.microsoft.com/config/sles/15/mssql-server-2022.repo
2019 CU 2019 sudo zypper addrepo -fc https://packages.microsoft.com/config/sles/15/mssql-server-2019.repo
2017 CU 2017 sudo zypper addrepo -fc https://packages.microsoft.com/config/sles/12/mssql-server-2017.repo

Configure the new repository to use for SQL Server installations and upgrades.

Note

  • Starting with SQL Server 2022 (16.x) CU 10, Ubuntu 22.04 is supported
  • Starting with SQL Server 2019 (15.x) CU 10, Ubuntu 20.04 is supported
  • Starting with SQL Server 2019 (15.x) CU 3 and SQL Server 2017 (14.x) CU20, Ubuntu 18.04 is supported.
  • The following commands points to the Ubuntu 18.04 repository. If you use Ubuntu 18.04, change the path below to /ubuntu/18.04 instead of /ubuntu/20.04.
  1. Import the public repository GPG keys.

    curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc
    
  2. Use one of the following commands to configure the repository of your choice.

    Repository Version Command
    2022 2022 sudo add-apt-repository "$(curl https://packages.microsoft.com/config/ubuntu/22.04/mssql-server-2022.list)"
    2019 CU 2019 sudo add-apt-repository "$(curl https://packages.microsoft.com/config/ubuntu/20.04/mssql-server-2019.list)"
    2017 CU 2017 sudo add-apt-repository "$(curl https://packages.microsoft.com/config/ubuntu/18.04/mssql-server-2017.list)"
  3. Run apt-get update.

    sudo apt-get update
    

After you have configured the correct repository, you can proceed to install or update SQL Server and any related packages from the new repository.

Important

At this point, if you choose to use the RHEL quickstart, remember that you have already configured the target repository. Don't repeat that step in the tutorials.

Important

At this point, if you choose to use the SLES quickstart, remember that you have already configured the target repository. Don't repeat that step in the tutorials.

Important

At this point, if you choose to use the Ubuntu quickstart, remember that you have already configured the target repository. Don't repeat that step in the tutorials.

For more information on how to install SQL Server on Linux, see Installation guidance for SQL Server on Linux.