How to Install SQL Tools on Redhat Linux without Internet – Offline Installation

I have described step by step process to install RedHat Enterprise Linux 7.3 and Offline installation of SQL Server 2017 on RHEL server in my last articles. Here I will explain step by step process to install SQL Server tools (sqlcmd and bcp) on server where you had already installed SQL Server 2017. We will use offline method to install SQL tools because our Linux server is running without an internet connection.

The mssql-tools package contains two utilities that will be installing with this process:

  • sqlcmd: Command-line query utility.
  • bcp: Bulk import-export utility.

We can easily install SQL tools on RHEL if we have internet access to the online repositories on the RHEL server but it’s bit complex to install SQL Server or SQL tools or any package if we don’t have internet access on the server. Here i will explain how to perform offline installation of SQL Server tools on RHEL which are running without internet connection.

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

SQL Tools Installation on RHEL – Offline/Without Internet

Installing any package on Redhat Linux is straight forward method if your server has internet connection and able to access online repositories. But it becomes little painful if your RHEL server has no access of internet. We generally call such installations as offline installation. Microsoft suggests below steps for offline installation of SQL Server Tools on Red Hat Linux server.

  • Download all sql tools related packages. i.e msodbc & mssql-tools
  • Move these downloaded packages to your Red Hat Linux Machine.
  • Install the copied rpm packages on the server.
  • Resolve Missing Dependencies, if you get any.
  • Set the Path environment Variables for this package.

Now we will go step by step process with the screenshots that will be helpful for readers to understand this process.

Download & Copy SQL Tools Packages to Linux Server

Before moving ahead let’s check whether SQL Server is installed or not on this machine. Run below command to check the SQL Server service.

#Check SQL Server Service
systemctl status mssql-server

check SQL Server Service

We can see SQL Server is installed and running fine on this server. Now you can just type sqlcmd to check sql tool is installed or not. We can see it is not installed yet. Next step is to start the package download and proceed with installation.

check sqlcmd is installed or not

Let’s start with downloading the rpm package for SQL Tools. You can download the required rpm packages from the attached link or from Microsoft Repositories. You can download these packages on a machine or PC which is connected to the internet. Below are the list of rpm packages which needs to be downloaded to install sql tools. Make sure to download latest packages from Microsoft Repositories. I downloaded below packages which is latest till date.

  • msodbcsql-13.1.9.0-1.x86_64.rpm
  • mssql-tools-14.0.5.0-1.x86_64.rpm

SQL Tools package depends on msodbcsql, which must be installed first to avoid any dependency issue.Once package will be downloaded to your local PC, next step is to copy above downloaded packages to the Red Hat Linux server that are running without internet connection.

You can use any tool, application or method to copy this file from localhost to Linux server. I used WinSCP tool to copy this file from machine where i have downloaded the package to the Linux server. Make sure that there should be connectivity between both machine.

If you have not installed WinSCP yet, download it and install on your PC. Launch WinSCP tool and make a connection to Red Hat Linux server. You can see i entered all details and credentials in below image to make connection with Linux server. Once you save the details, login button will be enabled. Click on Login button to establish connection.

WinSCP connection

There are two panes in WinSCp window. The files shows in left side pane is your local system and right side pane is your target Linux server.
winscp file copy

Now we just need to drag the downloaded rpm packages from left side pane and drop it to right side pane to copy it to Linux server and it will be done. You can see files are copied now and we can see the files in both side panes.

winscp file copy

You can see rpm packages are copied to location \home\techyaz\Packages\ in above screen. Now we can connect to Linux server and validate whether files are copied there or not. Connect to Linux server and check the files. We can see files there in below image.

check files on Linux

Installing SQL Tools

We can see downloaded files are very much there on Linux server. Now our next step is to install these packages. We will use the yum package to install it as we do for other applications on Linux. I used yum localinstall because we are installing SQL Server offline with the help of local package which we just copied from local host. Let’s install msodbc package first because this package will required to install mssql-tools package.

sudo yum localinstall msodbcsql-13.1.9.0-1.x86_64.rpm

We can see this package is failed to install because of a dependency unixODBC package. Now we need to install unixODBC version 2.3.1 or more on this system to resolve this dependency.

msodbc failed to install

Download the unixODBC package on your local host and copy it to Linux server using WinSCP as we did in above steps. You can see we have copied this file to Linux server in below image.

copy unixodbc

You can check and verify the copied file on Linux server by running ls -lrt command. We can see file is copied on the server.

Now install this package by running yum command.

sudo yum localinstall unixODBC-2.3.2-6.fc22.x86_64.rpm

Once installation will start, it will check dependencies and ask you to type y to proceed for the installation. Below is the image of the installation of this package.

unixODBC installation

Now we have installed the required package for msodbc package. Now go ahead and install this package again. Run below command to execute the installation.

sudo yum localinstall msodbcsql-13.1.9.0-1.x86_64.rpm

We can see dependency is resolved now for this package and installation has been processed. Setup will ask you to enter y to proceed with the installation. Type y and press enter to proceed.

msodbc installation

Once you press enter, setup will process and ask you to accept the license terms. Type YES to accept the license terms and press enter to proceed. Below image shows the successful installation of this package.

install msodbc

Next step is to install mssql-tools package. Run below command to start the installation process.

sudo yum localinstall mssql-tools-14.0.5.0-1.x86_64.rpm

Installation will proceed and ask you to enter y button to proceed as shown in below image. You can see the other details of this package as well.

install sql tools

Once you enter y, installation will resumed and again ask you to enter YES to accept the license terms. Type YES and press enter to proceed.

install sql tools

You can see SQL Server Tools have been installed on this server. Now go ahead and type sqlcmd and press enter to see whether Linux is recognizing this tool or not.

RHEL is still not able to recognized sql tools. To fix this issue, we will add /opt/mssql-tools/bin/ to your PATH environment variable in a bash shell. Run below command to get this done.

#To make sqlcmd/bcp accessible from the bash shell for login sessions, 
#modify your PATH in the ~/.bash_profile file.
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
#To make sqlcmd/bcp accessible from the bash shell for interactive/non-login sessions, 
#modify the PATH in the ~/.bashrc file
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc

path variable

Validate the Installation

Now execute sqlcmd again on Linux shell. This time you can see that Linux is able to recognize this utility.

We can also connect to SQL Server instance using newly installed tool and check the installed version of SQL Server just to verify that everything is working fine.

#Connect to SQL Server Instance using sa login. Enter the sa password once you get prompt.
sqlcmd -S192.168.209.133 -Usa
#Check SQL Server Version.
SELECT @@VERSION

You can see SQL Server 2017 (RC2) is installed on this machine.

Read below articles if you want to learn:

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.
Manvendra Deo Singh
Follow me:

You may also like...

Leave a Reply

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