| title | Get started with SQL Server 2017 on Red Hat Enterprise Linux | Microsoft Docs |
|---|---|
| description | This quickstart shows how to install SQL Server 2017 on Red Hat Enterprise Linux and then create and query a database with sqlcmd. |
| author | rothja |
| ms.author | jroth |
| manager | jhubbard |
| ms.date | 10/02/2017 |
| ms.topic | article |
| ms.prod | sql-non-specified |
| ms.prod_service | database-engine |
| ms.service | |
| ms.component | sql-linux |
| ms.suite | sql |
| ms.custom | |
| ms.technology | database-engine |
| ms.assetid | 92503f59-96dc-4f6a-b1b0-d135c43e935e |
| ms.workload | Active |
[!INCLUDEtsql-appliesto-sslinux-only]
In this quickstart, you first install SQL Server 2017 on Red Hat Enterprise Linux (RHEL) 7.3+. Then connect with sqlcmd to create your first database and run queries.
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.
You must have a RHEL 7.3 or 7.4 machine with at least 2 GB of memory.
To install Red Hat Enterprise Linux on your own machine, go to http://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.
For other system requirements, see System requirements for SQL Server on Linux.
To configure SQL Server on RHEL, run the following commands in a terminal to install the mssql-server package:
Important
If you have previously installed a CTP or RC release of SQL Server 2017, you must first remove the old repository before registering one of the GA repositories. For more information, see Change repositories from the preview repository to the GA repository.
-
Download the Microsoft SQL Server Red Hat repository configuration file:
sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2017.repo
[!NOTE] This is the Cumulative Update (CU) repository. For more information about your repository options and their differences, see Change source repositories.
-
Run the following commands to install SQL Server:
sudo yum install -y mssql-server
-
After the package installation finishes, run mssql-conf setup and follow the prompts to set the SA password and choose your edition.
sudo /opt/mssql/bin/mssql-conf setup
[!TIP] If you are trying SQL Server 2017 in this tutorial, the following editions are freely licensed: Evaluation, Developer, and Express.
[!NOTE] Make sure to specify a strong password for the SA account (Minimum length 8 characters, including uppercase and lowercase letters, base 10 digits and/or non-alphanumeric symbols).
-
Once the configuration is done, verify that the service is running:
systemctl status mssql-server
-
To allow remote connections, open the SQL Server port on the firewall on RHEL. The default SQL Server port is TCP 1433. If you are 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, SQL Server is running on your RHEL machine and is ready to use!
To create a database, you need to connect with a tool that can run Transact-SQL statements on the SQL Server. The following steps install the SQL Server command-line tools: sqlcmd and bcp.
-
Download the Microsoft Red Hat repository configuration file.
sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo
-
If you had a previous version of mssql-tools installed, remove any older unixODBC packages.
sudo yum remove unixODBC-utf16 unixODBC-utf16-devel
-
Run the following commands to install mssql-tools with the unixODBC developer package.
sudo yum install -y mssql-tools unixODBC-devel
-
For convenience, add
/opt/mssql-tools/bin/to your PATH environment variable. This enables you to run the tools without specifying the full path. Run the following commands to modify the PATH for both login sessions and interactive/non-login sessions:echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc source ~/.bashrc
Tip
Sqlcmd is just one tool for connecting to SQL Server to run queries and perform management and development tasks. Other tools include:
[!INCLUDE Connect, create, and query data]