SQL SERVER ON LINUX INSTALLATION – PART3 – INSTALL SQL SERVER COMMAND-LINE TOOLS ON RHEL

As installing SQL Server on Linux doesn’t install SQL Server command-line tools by default. So, you have to install it separately. In my previous tips of this series, I discussed how to create a virtual machine using Windows Hyper-V, how to install RHEL on the created virtual machine, and how to install SQL Server on the RHEL Server. Now, we will walk though a step by step SQL Server Command-Line Tools installation process.

The mssql-tools package contains Command Line utilities & Bulk Import-Export utilities. The SQLCMD utility allows users to connect to, send Transact-SQL batches from, and output rowset information from SQL Server instances. The BCP utility bulk copies data between an instance of Microsoft SQL Server and a data file in a user-specified format. Installing SQL Server Tools will also install the Microsoft ODBC driver and all its dependencies by default.

Step-by-Step process to install SQL Server Tools;

  • Connect to the RHEL virtual machine and log on to the server by keying username & password, and switch to root user
su root

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

  • Install the SQL Server Common Line Tools  with the unixODBC developer package run the following command;
sudo yum install -y mssql-tools unixODBC-devel

During the installation of the tool, it will prompt you to accept the license terms for MSSQL-Tools and Microsoft ODBC driver

  • By default, sqlcmd program is not in your environment variable PATH. So, you can take opt/mssql-tools/bin and add it to the Bash_profile path. Let’s run the below command. This enables you to run the tools without specifying the full path.
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc

  • Verify the connectivity of SQL Server on Linux machine using command line tool now
sqlcmd -S <Host Name OR IP> -U <Username> -P<P@ssw0rd>

Hope, enjoy the great Learning!

 

Leave a comment

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