SQL SERVER ON LINUX INSTALLATION – PART4 – Install SQL Server Tools on Ubuntu – Updated!

Installing SQL Server on Linux does not install SQL Server tools by default. You have to install it individually. In my previous posts of this series, I discussed how to create a virtual machine using Windows Hyper-V, how to install Ubuntu Server on the created virtual machine and how to install SQL Server on the Ubuntu Server. Now, we will walk though a step by step SQL Server 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;

  • If you are not logged on to the system as superuser mode, kindly switch to superuser mode

  • Import the public repository GPG keys

Syntax: curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add –

  • Register the Microsoft Ubuntu repository

Syntax: curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list

  • You need to run the below script to get all the latest updates from Ubuntu & Microsoft online servers

Syntax: sudo apt-get update

  • Install the SQL Server Tools  with with the unixODBC developer package – During the installation of the tool, it will prompt you to accept the license terms for MSSQL-Tools and Microsoft ODBC driver

Syntax: sudo apt-get install mssql-tools unixodbc-dev

MSSQL-TOOLS license terms message box prompt – click on “Yes”04
Microsoft ODBC driver license terms message box prompt – Click on “Yes”05
You will not see any message that says the tools have been installed successfully but do get installed.

  • Optional: Add /opt/mssql-tools/bin/ to your PATH environment variable in a bash shell.To make sqlcmd/bcp accessible from the bash shell for login sessions, modify your PATH in the ~/.bash_profile file with the following command:

Syntax: 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 with the following command:

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

Syntax: source ~/.bashrc

  • Verify the connectivity of SQL Server on Linux machine using command line tool now

Syntax: sqlcmd -S <hostname> -U <username> -P <password>

Wow! you have completed a successful installation of SQL Server on Linux on Windows hyper-v and learned a lot.  This was my last post of ‘SQL Server on Linux Installation’ series. Please do share you experience!

Leave a comment

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