Skip to content

Latest commit

 

History

History
438 lines (286 loc) · 22.8 KB

File metadata and controls

438 lines (286 loc) · 22.8 KB
title RHEL: Install SQL Server on Linux
titleSuffix SQL Server
description This quickstart shows how to install SQL Server on Red Hat Enterprise Linux (RHEL) and then create and query a database with sqlcmd.
author rwestMSFT
ms.author randolphwest
ms.date 01/27/2026
ms.service sql
ms.subservice linux
ms.topic quickstart
ms.custom
intro-installation
linux-related-content
ignite-2025

Quickstart: Install SQL Server and create a database on Red Hat Enterprise Linux

[!INCLUDE SQL Server - Linux]

::: moniker range="=sql-server-linux-2017 || =sql-server-2017"

In this quickstart, you install [!INCLUDE sssql17-md] on Red Hat Enterprise Linux (RHEL) 8.x. Then you connect by using sqlcmd to create your first database and run queries.

For more information on supported platforms, see Release notes for SQL Server 2017 on Linux.

::: moniker-end

::: moniker range="=sql-server-linux-ver15 || =sql-server-ver15"

In this quickstart, you install [!INCLUDE sssql19-md] on Red Hat Enterprise Linux (RHEL) 8.x. Then you connect by using sqlcmd to create your first database and run queries.

For more information on supported platforms, see Release notes for SQL Server 2019 on Linux.

::: moniker-end

::: moniker range="=sql-server-linux-ver16 || =sql-server-ver16"

In this quickstart, you install [!INCLUDE sssql22-md] on Red Hat Enterprise Linux (RHEL) 8.x or 9.x. Then you connect by using sqlcmd to create your first database and run queries.

If you want to automate your installation using Ansible, see Quickstart: Deploy SQL Server on Linux using an Ansible playbook.

For more information on supported platforms, see Release notes for SQL Server 2022 on Linux.

::: moniker-end

::: moniker range=">=sql-server-linux-ver17 || >=sql-server-ver17"

In this quickstart, you install [!INCLUDE sssql25-md] on Red Hat Enterprise Linux (RHEL) 9.x or 10.x. Then you connect by using sqlcmd to create your first database and run queries.

Note

Red Hat 9 includes support for [!INCLUDE sssql25-md] and TLS 1.3, which is enabled by default. Starting with [!INCLUDE sssql25-md] CU 1, Red Hat 10 is supported.

If you want to automate your installation using Ansible, see Quickstart: Deploy SQL Server on Linux using an Ansible playbook.

For more information on supported platforms, see Release notes for SQL Server 2025 on Linux.

::: moniker-end

Tip

This tutorial requires user input and an internet connection. If you're interested in the unattended or offline installation procedures, see Installation guidance for SQL Server on Linux. If you choose to have a preinstalled [!INCLUDE ssnoversion-md] VM on RHEL ready to run your production-based workload, follow the best practices for creating the SQL Server VM.

Prerequisites

You need a machine running RHEL 8.x with at least 2 GB of memory.

To install Red Hat Enterprise Linux on your own machine, go to https://access.redhat.com/products/red-hat-enterprise-linux/evaluation. You can also create RHEL virtual machines in Azure. See Create and Manage Linux VMs with the Azure CLI, and use --image RHEL in the call to az vm create.

::: moniker range="<=sql-server-linux-ver16 || <=sql-server-ver16"

If you previously installed a preview version of [!INCLUDE ssnoversion-md], you must first remove the old repository before following these steps. For more information, see Configure repositories for installing and upgrading SQL Server on Linux.

::: moniker-end ::: moniker range=">=sql-server-linux-ver17 || >=sql-server-ver17"

If you previously installed a preview version of [!INCLUDE ssnoversion-md], you must first remove the old repository before following these steps. For more information, see Configure repositories for installing and upgrading SQL Server 2025 on Linux.

::: moniker-end

For other system requirements, see System requirements for SQL Server on Linux.

To ensure you configure your [!INCLUDE ssnoversion-md] instance according to the recommended standards, see Performance best practices and configuration guidelines for SQL Server on Linux.

Install SQL Server

::: moniker range="=sql-server-linux-2017 || =sql-server-2017"

The following commands for installing [!INCLUDE ssnoversion-md] point to the RHEL 8 repository. RHEL 8 doesn't come with python2 preinstalled, but [!INCLUDE ssnoversion-md] requires it. Before you begin the [!INCLUDE ssnoversion-md] install steps, run the command and verify that python2 is selected as the interpreter:

sudo alternatives --config python
# If not configured, install python2 and openssl10 using the following commands:
sudo yum install python2
sudo yum install compat-openssl10
# Configure python2 as the default interpreter using this command:
sudo alternatives --config python

For more information, see the following blog on installing python2 and configuring it as the default interpreter: https://www.redhat.com/blog/installing-microsoft-sql-server-red-hat-enterprise-linux-8-beta.

To configure [!INCLUDE ssnoversion-md] on RHEL, run the following commands in a terminal to install the mssql-server package:

  1. Download the [!INCLUDE sssql17-md] Red Hat repository configuration file:

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

    [!TIP]
    If you want to install a different version of [!INCLUDE ssnoversion-md], see the SQL Server 2019, SQL Server 2022, or SQL Server 2025 versions of this article.

  2. Run the following command to install [!INCLUDE ssnoversion-md]:

    sudo yum install -y mssql-server
  3. After the package installation finishes, run mssql-conf setup by using its full path. Follow the prompts to set the sa password and choose your edition. As a reminder, the following [!INCLUDE ssnoversion-md] editions are freely licensed: Evaluation, Developer, and Express.

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

    [!CAUTION]
    [!INCLUDE password-complexity]

  4. When the configuration is done, verify that the service is running:

    systemctl status mssql-server
  5. To allow remote connections, open the [!INCLUDE ssnoversion-md] port on the RHEL firewall. The default [!INCLUDE ssnoversion-md] port is TCP 1433. If you're using FirewallD for your firewall, use the following commands:

    sudo firewall-cmd --zone=public --add-port=1433/tcp --permanent
    sudo firewall-cmd --reload

At this point, [!INCLUDE ssnoversion-md] is running on your RHEL machine and is ready to use.

::: moniker-end

::: moniker range="=sql-server-linux-ver15 || =sql-server-ver15"

The following commands for installing [!INCLUDE ssnoversion-md] point to the RHEL 8 repository. RHEL 8 doesn't come with python2 preinstalled, but [!INCLUDE ssnoversion-md] requires it. Before you begin the [!INCLUDE ssnoversion-md] install steps, run the command and verify that python2 is selected as the interpreter:

sudo alternatives --config python
# If not configured, install python2 and openssl10 using the following commands:
sudo yum install python2
sudo yum install compat-openssl10
# Configure python2 as the default interpreter using this command:
sudo alternatives --config python

For more information, see the following blog on installing python2 and configuring it as the default interpreter: https://www.redhat.com/blog/installing-microsoft-sql-server-red-hat-enterprise-linux-8-beta.

To configure [!INCLUDE ssnoversion-md] on RHEL, run the following commands in a terminal to install the mssql-server package:

  1. Download the [!INCLUDE sssql19-md] 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

    [!TIP]
    If you want to install a different version of [!INCLUDE ssnoversion-md], see the SQL Server 2017, SQL Server 2022, or SQL Server 2025 versions of this article.

  2. Run the following command to install [!INCLUDE ssnoversion-md]:

    sudo yum install -y mssql-server
  3. After the package installation finishes, run mssql-conf setup by using its full path. Follow the prompts to set the sa password and choose your edition. As a reminder, the following [!INCLUDE ssnoversion-md] editions are freely licensed: Evaluation, Developer, and Express.

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

    [!CAUTION]
    [!INCLUDE password-complexity]

  4. When the configuration is done, verify that the service is running:

    systemctl status mssql-server
  5. To allow remote connections, open the [!INCLUDE ssnoversion-md] port on the RHEL firewall. The default [!INCLUDE ssnoversion-md] port is TCP 1433. If you're using FirewallD for your firewall, use the following commands:

    sudo firewall-cmd --zone=public --add-port=1433/tcp --permanent
    sudo firewall-cmd --reload

At this point, [!INCLUDE ssnoversion-md] is running on your RHEL machine and is ready to use.

::: moniker-end

::: moniker range="=sql-server-linux-ver16 || =sql-server-ver16"

The following commands for installing [!INCLUDE ssnoversion-md] point to the RHEL 8 repository.

To configure [!INCLUDE ssnoversion-md] on RHEL, run the following commands in a terminal to install the mssql-server package:

  1. Download the [!INCLUDE sssql22-md] Red Hat 8 repository configuration file:

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

    [!TIP]
    If you want to install a different version of [!INCLUDE ssnoversion-md], see the SQL Server 2017 or SQL Server 2019 versions of this article.

  2. Run the following command to install [!INCLUDE ssnoversion-md]:

    sudo yum install -y mssql-server
  3. After the package installation finishes, run mssql-conf setup by using its full path. Follow the prompts to set the sa password and choose your edition. As a reminder, the following [!INCLUDE ssnoversion-md] editions are freely licensed: Evaluation, Developer, and Express.

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

    [!CAUTION]
    [!INCLUDE password-complexity]

  4. When the configuration is done, verify that the service is running:

    systemctl status mssql-server
  5. To allow remote connections, open the [!INCLUDE ssnoversion-md] port on the RHEL firewall. The default [!INCLUDE ssnoversion-md] port is TCP 1433. If you're using FirewallD for your firewall, use the following commands:

    sudo firewall-cmd --zone=public --add-port=1433/tcp --permanent
    sudo firewall-cmd --reload

At this point, [!INCLUDE ssnoversion-md] is running on your RHEL machine and is ready to use.

Starting with RHEL 9, you can run [!INCLUDE ssnoversion-md] as a confined application with SELinux enabled. For more information about confined and unconfined applications with SELinux, see Getting started with SELinux.

To run [!INCLUDE ssnoversion-md] as a confined application, follow these steps:

  • Ensure that SELinux is enabled and in enforcing mode.

  • Install the mssql-server package using the steps mentioned later in this section.

  • Install the new mssql-server-selinux package.

    sudo yum install -y mssql-server-selinux

Note

You can still install and run [!INCLUDE ssnoversion-md] as an unconfined application like in previous versions of RHEL.

To configure [!INCLUDE ssnoversion-md] on RHEL 9, run the following commands in a terminal to install the mssql-server package:

  1. Download the [!INCLUDE sssql22-md] Red Hat 9 repository configuration file:

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

    [!TIP]
    If you want to install a different version of [!INCLUDE ssnoversion-md], see the SQL Server 2017 or SQL Server 2019 versions of this article.

  2. Run the following command to install [!INCLUDE ssnoversion-md]:

    sudo yum install -y mssql-server

    Optionally, if you want to run [!INCLUDE ssnoversion-md] as a confined application, install the mssql-server-selinux package, which enables custom policies.

    sudo yum install -y mssql-server-selinux
  3. After the package installation finishes, run mssql-conf setup by using its full path. Follow the prompts to set the sa password and choose your edition. As a reminder, the following [!INCLUDE ssnoversion-md] editions are freely licensed: Evaluation, Developer, and Express.

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

    [!CAUTION]
    [!INCLUDE password-complexity]

  4. When the configuration is done, verify that the service is running:

    systemctl status mssql-server
  5. To allow remote connections, open the [!INCLUDE ssnoversion-md] port on the RHEL firewall. The default [!INCLUDE ssnoversion-md] port is TCP 1433. If you're using FirewallD for your firewall, use the following commands:

    sudo firewall-cmd --zone=public --add-port=1433/tcp --permanent
    sudo firewall-cmd --reload

At this point, [!INCLUDE ssnoversion-md] is running on your RHEL machine and is ready to use.


::: moniker-end

::: moniker range=">=sql-server-linux-ver17 || >=sql-server-ver17"

To configure [!INCLUDE ssnoversion-md] on RHEL 9, run the following commands in a terminal to install the mssql-server package:

  1. Download the [!INCLUDE sssql25-md] Red Hat 9 repository configuration file:

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

    [!TIP]
    If you want to install a different version of [!INCLUDE ssnoversion-md], see the SQL Server 2017, SQL Server 2019, or SQL Server 2022 versions of this article.

  2. Run the following command to install [!INCLUDE ssnoversion-md]:

    sudo yum install -y mssql-server

    Optionally, if you want to run [!INCLUDE ssnoversion-md] as a confined application, install the mssql-server-selinux package, which enables custom policies.

    sudo yum install -y mssql-server-selinux
  3. After the package installation finishes, run mssql-conf setup by using its full path. Follow the prompts to set the sa password and choose your edition. As a reminder, the following [!INCLUDE ssnoversion-md] editions are freely licensed: Evaluation, Developer, and Express.

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

    [!CAUTION]
    [!INCLUDE password-complexity]

  4. When the configuration is done, verify that the service is running:

    systemctl status mssql-server
  5. To allow remote connections, open the [!INCLUDE ssnoversion-md] port on the RHEL firewall. The default [!INCLUDE ssnoversion-md] port is TCP 1433. If you're using FirewallD for your firewall, use the following commands:

    sudo firewall-cmd --zone=public --add-port=1433/tcp --permanent
    sudo firewall-cmd --reload

At this point, [!INCLUDE ssnoversion-md] is running on your RHEL machine and is ready to use.

To configure [!INCLUDE ssnoversion-md] on RHEL 10, run the following commands in a terminal to install the mssql-server package:

  1. Download the [!INCLUDE sssql25-md] Red Hat 10 repository configuration file:

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

    [!TIP]
    If you want to install a different version of [!INCLUDE ssnoversion-md], see the SQL Server 2017, SQL Server 2019, or SQL Server 2022 versions of this article.

  2. Run the following command to install [!INCLUDE ssnoversion-md]:

    sudo yum install -y mssql-server

    Optionally, if you want to run [!INCLUDE ssnoversion-md] as a confined application, install the mssql-server-selinux package, which enables custom policies.

    sudo yum install -y mssql-server-selinux
  3. After the package installation finishes, run mssql-conf setup by using its full path. Follow the prompts to set the sa password and choose your edition. As a reminder, the following [!INCLUDE ssnoversion-md] editions are freely licensed: Evaluation, Developer, and Express.

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

    [!CAUTION]
    [!INCLUDE password-complexity]

  4. When the configuration is done, verify that the service is running:

    systemctl status mssql-server
  5. To allow remote connections, open the [!INCLUDE ssnoversion-md] port on the RHEL firewall. The default [!INCLUDE ssnoversion-md] port is TCP 1433. If you're using FirewallD for your firewall, use the following commands:

    sudo firewall-cmd --zone=public --add-port=1433/tcp --permanent
    sudo firewall-cmd --reload

At this point, [!INCLUDE ssnoversion-md] is running on your RHEL machine and is ready to use.


::: moniker-end

Disable the SA account as a best practice

[!INCLUDE connect-with-sa]

Install the SQL Server command-line tools

To create a database, you need to connect to the [!INCLUDE ssnoversion-md] instance using a tool that can run Transact-SQL statements. The following steps install the [!INCLUDE ssnoversion-md] command-line tools: sqlcmd utility and bcp utility.

[!INCLUDE odbc-redhat]

[!INCLUDE Connect, create, and query data]