Installing SQL Tools on Red Hat Linux

I have shown you how to install SQL Server on Redhat Linux Server in my last article. Here I will explain step by step process to install SQL Tools on RedHat Linux 7.3 server. Installing SQL Tools will install sqlcmd and bcp utilities on this RHEL server.

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.

If you have installed SQL Server on Red Hat Linux server, you need to install SQL Tools to make database connection locally on the server. Make sure you have internet access on the Linux server where we are going to install SQL Tools. If your server does not have internet connection then you should read attached article about installing SQL Tools on RedHat Linux that are running without Internet.

Install SQL Tools on RHEL

As this Linux machine has internet connection so installing SQL Tools on this Linux machine will be quite easy. Let’s go ahead with the SQL Tools Installation on Red Hat Linux server that are connected to internet. Installation process is quite similar to the installation of SQL Server on Redhat Linux.

Let us first check the SQL Server service to make sure SQL Server is installed on this machine. Run below command to check the service.

#Check SQL Server Services
systemctl status mssql-server

Check SQL Server Service

We can see SQL Server is installed on this machine. Now check SQL Tools are installed on this machine or not by running sqlcmd utility. We can see this tool is not installed yet.

check sqlcmd

Now we will download the Microsoft SQL Tools Redhat repository configuration file by running below command to start the SQL Tools installation.

#Download Microsoft Red Hat repository configuration file
sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo

You can see file is downloaded to the given folder location. You can see this in below screenshot.

download sql tools repository

Run below commands to install SQL Tools along with unixODBC package on this server. We need to install unixODBC because of dependency issue. First update all packages by running below command.

#Run package update.
sudo yum update

Once package update will complete. Run below command to install SQL Tools. Once you execute below command, a series of execution will start and show you the details of package that are going to install.

#Install SQL Tools.
sudo yum install -y mssql-tools unixODBC-devel

After series of execution, setup will ask you to accept the license terms. Type YES to accept the license terms.

Install SQL Tools

I pressed enter button post accepting the license terms, again a series of execution started and SQL tools installation was completed within minutes.

install sqlcmd

Once SQL Tools will install, you can go ahead and check sqlcmd utility. If your Linux server is not able to recognize SQL Server Tools utilities sqlcmd or bcp we need to set path environment variables. Although, it is optional step but you should run below commands to add /opt/mssql-tools/bin/ to your PATH environment variable.

#Add /opt/mssql-tools/bin/ to your PATH environment variable.
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc

Path variables

Let us see whether Linux is able to recognize SQL Tool or not in below screenshot. We can see now sqlcmd is throwing output.

Check sqlcmd

Now you can go ahead and connect to your SQL Server instance locally by using sqlcmd tool. You can see i have connected to SQL Server Instance using sqlcmd in below screen.

connect using sqlcmd

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

Manvendra Deo Singh
Follow me:

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *