Step-by-Step Guide: How to install SQL Server 2019 on RHEL 8

SqlServerOnLatest rhel8 featuredimage

In this tutorial, we will be looking at how to install SQL server 2019 on RHEL 8. Before we can begin, please see the table below for a list of minimum prerequisites that we must fulfill before proceeding with installing SQL Server 2019 on RHEL 8. For this tutorial, I will assume that you already have a machine loaded with RHEL 8 (or RHEL 7) and that you have root access or access to sudo.

Memory2 GB
File SystemXFS or EXT4 (other file systems, such as BTRFS, are unsupported)
Disk space6 GB
Processor speed2 GHz
Processor cores2 cores
Processor typex64-compatible only
OSFor this tutorial RHEL 8
Step 1: Install Python

To begin let us first install Python2 on our RHEL 8 machine which is required by SQL Server. We can achieve this by executing the commands below individually:

sudo yum install python2
sudo yum install compat-openssl10

Sql server 2019 on rhel 8, installing python 2

After the installation is completed, we will now need to configure python2 as the default interpreter by running the command below and selecting option #2:

sudo alternatives --config python

Python2 config

Step 2: Download SQL Server 2019 repo files

Our next step is to download the Sql Server 2019 Red hat repository configuration files by running the command below. It is important to note that if your O.S is RHEL 7, you should change /rhel/8 to /rhel/7 in the command below. Now copy, paste and execute the command below on your command line:

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

[section label=”Install SQL Server 2019″]

Step 3: Install SQL Server 2019 on RHEL 8

Now it’s time to install SQL server 2019 on RHEL 8. To proceed, copy, paste and execute the command below. For your convenience a GIF outlining the process is shown below.

sudo yum install -y mssql-server

How to install SQL server 2019 on RHEL 8

Once the installation is completed successfully, we will get a confirmation and a list of packages that were installed. Please see the screenshot below of what this looks like.

Sql server 2019 on Rhel 8 packages installed

Step 4: SQL Server 2019 Setup

After completing the package installation we now need to setup SQL Server 2019. The setup will allow you to select SQL Server version and set the SA password. Execute the command below to achieve this and follow the instructions on screen.

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

The options are as follows:

Choose an edition Of SQL Server

Do you accept the license terms? [Yes/No]

Enter the SQL Server system administrator password:

Please see screenshot below:

Sql server 2019 on rhel 8 setup options

Step 4: Allow connections

Now that the setup is completed, we want to allow remote connections to our database instance. To allow remote connections to our instance we need to make changes to our firewall on RHEL 8 and allow access through port 1433 (SQL Sever default port. Change if you are installing SQL Server in a production environment). Please see the command  that will allow you to access the database instance through port 1433.

sudo firewall-cmd --zone=public --add-port=1433/tcp --permanent 
sudo firewall-cmd --reload
Step 5: Install SQL Server Command-line tools

This step we will install sqlcmd and bcp which will allow us to enter Transact-SQL statements, system procedures, and script files through the command prompt. First we need to Download the Microsoft Red Hat repository configuration file by running. Again if you are on RHEL 7, remember to change /rhel/8 to rhel/7.

sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/8/prod.repo

N.B if you had a previous version of mssql-tools installed, you will need to remove the older unixODBC packages by running:

sudo yum remove unixODBC-utf16 unixODBC-utf16-devel

Run the command below to install the unixODBC developer package.

sudo yum install -y mssql-tools unixODBC-devel

Add /opt/mssql-tools/bin to your environment PATH variable by running:

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

To test, run:

echo $PATH
Step 6: Connect to the instance

So you’re now at step 6, which means the installation was successful for you. Now its time to connect to and utilize our newly installed SQL Server  2019.  TO connect to the instance locally, run the command below and enter your password where necessary. As you can see in the tutorial GIF below, I am able to connect to my instance and query the master database.

sqlcmd -S localhost -U SA -P '<YourPassword>'

Connecting to sql server 2019 database on rhel 8

[section label=”Conclusion”]

Conclusion

This tutorial on how to install SQL Server 2019 on RHEL 8 seeks to simplify the installation guide that is provided by Microsoft. If followed correctly the installation process should take no more that 15 minutes.

Other Posts on SQL Server