Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Permalink
live
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
title titleSuffix description author ms.author ms.reviewer 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.
VanMSFT
vanto
randolphwest
10/20/2022
sql
linux
conceptual
seo-lt-2019
intro-installation

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

For more information on supported platforms, see [Release notes for [!INCLUDEsssql22] on Linux](sql-server-linux-release-notes-2022.md).

::: moniker-end

[!TIP]
This tutorial requires user input and an internet connection. If you are interested in the unattended or offline installation procedures, see Installation guidance for SQL Server on Linux. If you choose to have a pre-installed SQL Server VM on RHEL ready to run your production-based workload, then please 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 SQL Server. SQL Server Azure VMs deployed on RHEL using the above Marketplace images, are fully supported by both Microsoft and Red Hat.

You can configure SQL Server 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.0 - 8.6 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 Linux repositories for SQL Server.

For other system requirements, see System requirements 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

    Remember to specify a strong password for the SA account. You need a minimum length 8 characters, including uppercase and lowercase letters, base-10 digits and/or non-alphanumeric symbols.

  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

    Remember to specify a strong password for the SA account. You need a minimum length 8 characters, including uppercase and lowercase letters, base-10 digits and/or non-alphanumeric symbols.

  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 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

    Remember to specify a strong password for the SA account. You need a minimum length 8 characters, including uppercase and lowercase letters, base-10 digits and/or non-alphanumeric symbols.

  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

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 and bcp.

  1. Download the Red Hat repository configuration file.

    sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/8/prod.repo
  2. If you had a previous version of mssql-tools installed, remove any older unixODBC packages.

    sudo yum remove unixODBC-utf16 unixODBC-utf16-devel
  3. Run the following commands to install mssql-tools with the unixODBC developer package. For more information, see Install the Microsoft ODBC driver for SQL Server (Linux).

    sudo yum install -y mssql-tools unixODBC-devel
  4. For convenience, add /opt/mssql-tools/bin/ to your PATH environment variable, to make sqlcmd or bcp accessible from the bash shell.

    For interactive sessions, modify the PATH environment variable in your ~/.bash_profile file with the following command:

    echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile

    For non-interactive sessions, modify the PATH environment variable in your ~/.bashrc file with the following command:

    echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
    source ~/.bashrc

[!INCLUDE Connect, create, and query data]