Skip to content

Latest commit

 

History

History
330 lines (215 loc) · 17.5 KB

quickstart-install-connect-red-hat.md

File metadata and controls

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

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

[!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 can connect with 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 can connect with 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 can connect with sqlcmd to create your first database and run queries.

If you would like 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

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.

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

Azure Marketplace images

You can create your VM based on the following Azure Marketplace image:

When you use the above marketplace image, you avoid the installation step, and can directly configure the instance by providing the SKU and the sa password needed to get started with [!INCLUDE ssnoversion-md]. [!INCLUDE ssnoversion-md] Azure VMs deployed on RHEL using the above Marketplace images, are fully supported by both Microsoft and Red Hat.

You can configure [!INCLUDE ssnoversion-md] on Linux with mssql-conf, using the following command:

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

::: moniker-end

Prerequisites

You must have a RHEL 8.x machine 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.

If you've previously installed a Community Technology Preview (CTP) or Release Candidate (RC) 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.

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 preinstalled with python2, which is required by [!INCLUDE ssnoversion-md]. Before you begin the [!INCLUDE ssnoversion-md] install steps, execute 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/en/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 [[!INCLUDE sssql19-md]](quickstart-install-connect-red-hat.md?view=sql-server-linux-ver15&preserve-view=true#install) or [[!INCLUDE sssql22-md]](quickstart-install-connect-red-hat.md?view=sql-server-linux-ver16&preserve-view=true#install) 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 using its full path, and 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. Once 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, you can 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 preinstalled with python2, which is required by [!INCLUDE ssnoversion-md]. Before you begin the [!INCLUDE ssnoversion-md] install steps, execute 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/en/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 [[!INCLUDE sssql17-md]](quickstart-install-connect-red-hat.md?view=sql-server-linux-2017&preserve-view=true#install) or [[!INCLUDE sssql22-md]](quickstart-install-connect-red-hat.md?view=sql-server-linux-ver16&preserve-view=true#install) 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 using its full path, and 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. Once 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, you can 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 [[!INCLUDE sssql17-md]](quickstart-install-connect-red-hat.md?view=sql-server-linux-2017&preserve-view=true#install) or [[!INCLUDE sssql19-md]](quickstart-install-connect-red-hat.md?view=sql-server-linux-ver15&preserve-view=true#install) 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 using its full path, and 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. Once 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, you can 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 [[!INCLUDE sssql17-md]](quickstart-install-connect-red-hat.md?view=sql-server-linux-2017&preserve-view=true#install) or [[!INCLUDE sssql19-md]](quickstart-install-connect-red-hat.md?view=sql-server-linux-ver15&preserve-view=true#install) 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 using its full path, and 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. Once 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, you can 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 with a tool that can run Transact-SQL statements on [!INCLUDE ssnoversion-md]. 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]