Rajendra Gupta
SQL Server 2019

How to install SQL Server 2019 on RedHat Linux 18

December 9, 2020 by

In this article, we will learn to install SQL Server 2019 on the RedHat Linux 18 on a virtual machine.

Introduction

SQL 2019 evolves itself from a traditional relational database. You can integrate it with various relational, non-relational data using Apache, Big data clusters, Hadoop. It is available on both Windows and Linux operating systems.

SQL Server 2019

Image Reference: Microsoft

You should be familiar with SQL Server 2019 installation on both Windows and Linux (RedHat, Ubuntu or SUSE Linux) systems. In this article, we implement the following tasks.

  • Prepare a virtual machine for RedHat Linux 18
  • Install and Configure SQL Server 2019 on top of the Virtual Machine

Prepare a virtual machine for RedHat Linux 18

To create a Virtual machine, we need to have virtualization software such as Oracle VirtualBox. You can browse to URL and download the latest version VirtualBox6.1.

virtual machine for RedHat Linux 18

You can follow the installation wizard and install it on your machine. Once you have installed it, click on New for deploying the new VM.

deploying the new VM

In the Create Virtual Machine, specify a VM name, folder to store the VM related files, and select the OS type (Linux) along with version (Red-Hat).

In the memory size, give the appropriate memory for SQL Server VM. For this training environment, I use 4096MB memory.

Create Virtual Machine

Click ok Create and select the hard disk file type, size. We can go with the VDI file type and 30 GB space for it.

select the hard disk file

Click on Create and start the VM machine. You download the ISO file for the RedHat Linux 18 before proceeding further.

During the startup, it asks for the ISO file of the RedHat operating system. In the screenshot, it shows a 7.86 GB ISO file size.

The ISO file of the RedHat operating system

It starts the RedHat Enterprise Linux 18.2 setup, as shown below.

RedHat Enterprise Linux 18.2 setup

RedHat Enterprise Linux 18.2 setup 01

In the beginning, select your installation language. It automatically detects your VM language.

Detects your VM language

Click on Continue. In the Installation summary, you get various configurations for Localization, software and system.

the Installation summary

Click on the Installation Destination under the system category. You can make drive partitions on this page, but we can go with the default partition for our RedHat OS.

Installation Destination

Now, you do not see any error for the installation destination. Click on Begin Installation.

Begin Installation

While the RedHat installation is in progress, it requires input for the Root password and a RedHat user.

Root password

Click on Create User and fill up your user name, passwords.

Click on Create User

Similarly, click on Root Password and specify the password for the root user. You require this password for performing administrative work in RedHat OS.

specify the password for the root user

Now, RedHat Enterprise Linux is installed successfully. You can reboot the VM and start using the VM for SQL installations.

reboot the VM

Before the reboot, click on License information and accept the license terms conditions.

license terms conditions

Click on Finish Configuration.

Finish Configuration

Once the VM is up, log in with your administrator credentials and launch the terminal. We need to provide the subscription information for your RHEL account credentials using the following query:

$ subscription-manager register –username Rajendra.gupta16@gmail.com –password ******** –auto-attach

subscription-manager

By default, Oracle VirtualBox assigns a name for your virtual machine. We need to change it to our desired hostname using the following command.

$sudo vi /etc/hostname

You can verify the new hostname using the cat command below

$sudo cat /etc/hostname

name for your virtual machine

Install Python2 on RedHat Enterprise Linux

SQL Server 2019 uses Python and OpenSSL for the SQL Server installation. You can install Python2 using the following command in the terminal.

$ sudo yum install python2

Install Python2 on RedHat Enterprise Linux

Install Python2 on RedHat Enterprise Linux -1

Install OpenSSL on RedHat Enterprise Linux

Once we have installed the Python2 on the RedHat Linux server, we can install the OpenSSL as well with the following code.

$ sudo yum install compat-openssl10

Install OpenSSL

Install OpenSSL - 1

Now, we need to set the defaults for the Python in the RedHat system. We use Python2 as a default interpreter for the SQL 2019. To set the defaults, use the following command.

$ sudo alternatives –config python

It gives you a list of Python version. Enter the selection number, and it creates a symlink for your SQL Server. Here, we select option 3 for Python2.

defaults for the Python

Install Microsoft SQL Server 2019 on RedHat Linux Enterprise Server

We are now ready to deploy the SQL 2019 on the RedHat Linux Enterprise Server.

Step 1: Download the SQL 2019 Red Hat repository configuration file

In this step, you use the CURL command in RedHat and download the SQL Server 2019 repository configuration file from Microsoft URL.

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

Download the SQL 2019

You can browse the URL in a browser to check the existing repositories.

existing repositories

Step 2: Install SQL Server 2019

In this step, we install the SQL 2019 from the repository we downloaded in the earlier step.

$ sudo yum install -y mssql-server

Install SQL Server

Install SQL Server .continued

Install SQL Server  - part 3

Step3: Configuring SQL Server 2019

In the Windows SQL Server, the installation wizard gives you the option to choose and based on those inputs, and it installs SQL Server features.

In the SQL Server on Linux, we install the base set up and then configure SQL Server using the mssql-conf utility.

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

Inputs required:

  • Edition of SQL Server: Enter the numeric value for the edition, we wish to install. For example, for the evaluation edition, you enter value 1

    Configuring SQL 2019

  • SQL Server administrator (SA) password
  • Accept license terms

     SQL Server administrator ( SA) password

It installs the SQL 2019 on the RedHat Linux Enterprise server and starts the services. To check the SQL service status, run the following command.

$ sudo systemctl status mssql-server

MSSQL Server service is in the running status, as shown below.

MSSQL Server service

Installing SQL Server command-line tools

You can connect the SQL Server on Linux using the following ways.

  • SQL Server Management Studio: You can install SSMS for only a Windows server. The firewall must allow connection from Windows to RedHat Linux Server
  • Azure Data Studio: You can install Azure Data Studio on the Linux server as well
  • SQL CMD: You can install the SQLCMD as a client tool to execute your

To install the SQLCMD client tool, use the following steps.

Step 1: Download the SQL Server 2019 Red Hat repository configuration file

Download the repository for the SQL Server client tools with the following command.

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

SQL Server command-line tools

Step 2: Install mssql-tools and unixODBC developer package

To install the install mssql-tools with the unixODBC developer package, run the following command in the terminal.

$ sudo yum install -y mssql-tools unixODBC-devel

unixODBC developer package

Accept the license terms.

Accept the license terms

Step 3: Add the client tools path in the PATH (environment variables)

SQL client tools are installed in the /opt/mssql-tools/bin directory. We can add it to the PATH environment variable for using the SQLCMD without specifying the /opt/mssql-tools/bin directory.

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

Add the client tools path in the PATH

Now, connect to the SQL Server 2019 Linux on RedHat Enterprise Server using the SQLCMD.

$ sqlcmd -s localhost -U SA -P India@123

connect to the SQL 2019 Linux

Install Azure Data Studio on RedHat Linux Enterprise Server

Browse to Microsoft Docs URL and download the Linux based Azure Data Studio.

Azure Data Studio on RedHat Linux Enterprise Server

Click on Install, and it quickly installs the ADS in your RedHat Linux.

ADS in your RedHat Linux.

After the ADS installation, click on Launch to connect with the SQL Server.

Launch to connect

In the new connection window, specify server name (you can use the localhost if you connect within the RedHat server terminal), authentication type (SQL login) and the credentials.

Connection details

In the ADS dashboard, you can view the details as the following:

  • Version: 15.0.4063.15
  • Edition: Developer edition( 64-bit)
  • Computer name: Rhel1
  • OS version: RedHat Enterprise Linux 8.2 (Oopta)

ADS dashboard

Conclusion

In this article, we configured a RedHat Enterprise Server virtual machine and installed SQL Server 2019 Linux on it. Further, we explored the client tools SQLCMD and Azure Data Studio for executing SQL queries.

Rajendra Gupta
Installation, setup and configuration, Linux, SQL Server 2019, SQL Server on Linux

About Rajendra Gupta

As an MCSA certified and Microsoft Certified Trainer in Gurgaon, India, with 13 years of experience, Rajendra works for a variety of large companies focusing on performance optimization, monitoring, high availability, and disaster recovery strategies and implementation. He is the author of hundreds of authoritative articles on SQL Server, Azure, MySQL, Linux, Power BI, Performance tuning, AWS/Amazon RDS, Git, and related technologies that have been viewed by over 10m readers to date. He is the creator of one of the biggest free online collections of articles on a single topic, with his 50-part series on SQL Server Always On Availability Groups. Based on his contribution to the SQL Server community, he has been recognized with various awards including the prestigious “Best author of the year" continuously in 2020 and 2021 at SQLShack. Raj is always interested in new challenges so if you need consulting help on any subject covered in his writings, he can be reached at rajendra.gupta16@gmail.com View all posts by Rajendra Gupta

2,036 Views