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
sachit@vnextnode:~$ sudo su [sudo] password for sachit:
- Import the public repository GPG keys
Syntax: curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add –
root@vnextnode:/home/sachit# curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 983 100 983 0 0 3656 0 --:--:-- --:--:-- --:--:-- 3667 OK root@vnextnode:/home/sachit#
- 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
root@vnextnode:/home/sachit# curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 79 100 79 0 0 304 0 --:--:-- --:--:-- --:--:-- 303 deb [arch=amd64] https://packages.microsoft.com/ubuntu/16.04/prod xenial main root@vnextnode:/home/sachit#
- You need to run the below script to get all the latest updates from Ubuntu & Microsoft online servers
Syntax: sudo apt-get update
root@vnextnode:/home/sachit# sudo apt-get update Get:1 https://packages.microsoft.com/ubuntu/16.04/prod xenial InRelease [2,845 B] Hit:2 https://packages.microsoft.com/ubuntu/16.04/mssql-server xenial InRelease Get:3 https://packages.microsoft.com/ubuntu/16.04/prod xenial/main amd64 Packages [8,047 B] Hit:4 http://us.archive.ubuntu.com/ubuntu xenial InRelease Get:5 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB] Get:6 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB] Get:7 http://us.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB] Fetched 317 kB in 1s (165 kB/s) Reading package lists... Done root@vnextnode:/home/sachit#
- 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”
Microsoft ODBC driver license terms message box prompt – Click on “Yes”
You will not see any message that says the tools have been installed successfully but do get installed.
Setting up odbcinst1debian2:amd64 (2.3.1-4.1) ... Setting up odbcinst (2.3.1-4.1) ... Setting up unixodbc (2.3.1-4.1) ... Setting up msodbcsql (13.1.8.0-1) ... Setting up mssql-tools (14.0.6.0-1) ... Setting up unixodbc-dev (2.3.1-4.1) ... Processing triggers for libc-bin (2.23-0ubuntu7) ...
- 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
root@vnextnode:/home/sachit# echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile root@vnextnode:/home/sachit#
- 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
root@vnextnode:/home/sachit# echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc root@vnextnode:/home/sachit#
Syntax: source ~/.bashrc
root@vnextnode:/home/sachit# source ~/.bashrc root@vnextnode:/home/sachit#
- Verify the connectivity of SQL Server on Linux machine using command line tool now
Syntax: sqlcmd -S <hostname> -U <username> -P <password>
root@vnextnode:/home/sachit# sqlcmd -S localhost -U sa -P XXXXX 1> select @@version 2> go ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------- Microsoft SQL Server 2017 (CTP2.1) - 14.0.600.250 (X64) May 10 2017 12:21:23 Copyright (C) 2017 Microsoft Corporation. All rights reserved. Developer Edition (64-bit) on Linux (Ubuntu 16.04.1 LTS) (1 rows affected) 1>
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!
One thought on “SQL SERVER ON LINUX INSTALLATION – PART4 – Install SQL Server Tools on Ubuntu – Updated!”
Hi Dharmendra,
Thanks for sharing SQL Server Installation in Linux environment (UBUNTU). I appreciate your efforts, but I need SQL server installation, configuration, and maintenance in RHEL 7.4 Server.
I request you to share articles for the same.
Best Regards,
Balakrishna M