How to Install SQL Server on Redhat Linux

Earlier SQL Server used to run only on Windows platform till SQL Server 2016 version. Now we can host our applications on Linux based SQL Server Instances. Here I will explain step by step process to install SQL Server on RedHat Linux 7.3 server.

Prerequisites

Before going ahead, we need to have a RedHat Linux server. If you have no idea about installing Linux server or creating a virtual machine where you can install Linux and SQL Server then i would recommend you to read below articles first.

Below are the prerequisites that needs to have on your virtual machine in order to install SQL Server 2017.

  • A Red Hat Linux Machine having Internet Connection
  • RAM – 3.25GB
  • Disk Space – 6GB
  • Processor speed – 2 GHz
  • Processor cores – 2 cores
  • Processor type – x64

Install SQL Server 2017 on RHEL

Installing SQL Server 2017 on Redhat Linux is straight forward method if your server has internet connection and able to access online repositories. But if your Red Hat Linux machine does not have internet connection you can go with attached article Offline Installation of SQL Server 2017 on Red Hat Linux. Let us go with the SQL Server Installation on Redhat Linux server that have internet connection.

Connect to RHEL server locally or through PuTTY. Check whether SQL Server is previously installed on this machine by someone else or not. You can see SQL Server is not installed, we can see it by checking the SQL Server service. Now download the Microsoft SQL Server Redhat repository configuration file by running below curl command.

#Download Microsoft SQL Server Redhat repository configuration file
sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server.repo

Next step is to install SQL Server on Linux machine. Run below command to update all package repository on Red Hat Linux server.

#Update Packages
sudo yum update

#Install SQL Server
sudo yum install -y mssql-server

I ran installation command which is showing in below image. A series of execution will start followed by checking the dependencies. If you will face any dependency issue, you should first resolve all missing dependencies then proceed with the installation. Setup will process and show you details of the packages which will be installing. You can see the details in below image.

SQL Server package is in downloading process. Once download will complete, installation process will start. This will take few minutes to install the package.

Now you can see SQL Server database engine is installed on this Redhat Linux server. Installation is not completed yet because setup suggests us to run mssql-conf utility to complete the installation. So next step is to run this process.

Setup is suggesting us to install a mssql-conf utility to accept the license terms and set the sa password. Run below command to configure SQL Server.

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

This execution will ask us to accept the License terms, select the SQL Server edition and also tell us to set the sa password. Let us do that to complete this installation. Once you execute above command, it will ask as to enter YES to access the license terms. Type YES and press enter. Once you press enter post accepting license terms, setup will give you options to choose SQL Server edition. Select correct edition as per your requirement.

Once you choose SQL Server edition, it will ask you to set sa login password. The moment you set the sa password, SQL Server configuration will be completed and ready to use.

Now SQL Server is installed, but sometimes you may face issue connecting to your SQL Server instance. You need to run below commands to open the SQL Server port on the firewall on the Linux server.

#Open Firewall for SQL Server
sudo firewall-cmd --zone=public --add-port=1433/tcp --permanent
sudo firewall-cmd --reload

You can see above commands executed successfully. Port 1433 is already enabled on my machine. If this port is not open on your server it will display as success. Now, you can check the SQL Server service to validate this installation. Run the same command which we have run to check the SQL Server service before starting the installation.

#Check SQL Server Service
systemctl status mssql-server


Now your SQL Server is ready to use. You can connect to this instance using SSMS client tool. You can see i have connected to this instance using SSMS from my local host computer.

If you want to connect to SQL Server on this server only. You need to connect using sqlcmd utility. By default, sqlcmd tool does not install on Linux machine. We need to manually install it. Please visit this attached article to understand step by step process of installing SQL Tools on a Red Hat Linux Server. If you don’t have internet access you can follow another article to install SQL Tools on Redhat Linux server in Offline mode.

If your Linux virtual machine doesn’t have Internet connection, you should read:

I hope you like this article. Please follow us on our facebook page and on Twitter handle to get latest updates.

Follow me:
Manvendra Deo Singh: I am working as a Technical Architect in one of the top IT consulting firm. I have expertise on all versions of SQL Server since SQL Server 2000. I have lead multiple SQL Server projects like consolidation, upgrades, migrations, HA & DR. I love to share my knowledge. You can contact me on my social accounts for any consulting work.
Related Post
Leave a Comment