Step by Step Process to Install SQL Tools on Ubuntu Server running without Internet – Offline Installation
I have described step by step process to install Ubuntu 16.04 Server and Offline installation of SQL Server 2017 on Ubuntu server in my last articles. Here I will explain step by step process to install SQL Server tools (sqlcmd and bcp) on Ubuntu server where you had already installed SQL Server 2017. This article will describe the offline method to install SQL tools. The mssql-tools package which we will install contains two utilities:
- sqlcmd: Command-line query utility.
- bcp: Bulk import-export utility.
Before going ahead, we need a Ubuntu server and SQL Server 2017 running on that instance. If you have no idea about installing Ubuntu server or SQL Server 2017 or creating a virtual machine where you can install Ubuntu and SQL Server then i would recommend you to read below articles.
- How to Create a Virtual Machine.
- How to Install Ubuntu Linux Server on a virtual machine
- Installing SQL Server 2017 on Ubuntu Server – Offline Installation
SQL Tools Installation on Ubuntu – Offline/Without Internet
Installing any package on Ubuntu Linux is straight forward method if your server has internet connection and able to access online repositories. But it becomes painful if your Ubuntu 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 Ubuntu server.
- Download all sql tools related packages. i.e msodbc & mssql-tools
- Move these downloaded packages to your Ubuntu Server.
- Install the copied debian packages on the server.
- Resolve Missing Dependencies, if you get any.
- Set the Path environment Variables for this package.
Now we will follow step by step process with the screenshots that will help readers to understand this process.
Download & Copy SQL Tools Packages to Ubuntu 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
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. As we can see SQL Tools are not installed so next step will package download and installation of that package.
Let’s start with downloading the debian package for SQL Tools. You can download the required SQL Tools debian packages for Ubuntu from the attached link or from Microsoft Repositories. You can download these packages on a machine or PC that is connected to the internet. Below are the list of debian packages which needs to be downloaded to install sql tools.
SQL Tools package installation depends on msodbcsql package that must be installed first to avoid any dependency issue. Once package will be downloaded on your local PC, next step is to copy above downloaded packages to the Ubuntu server that are running without internet connection.
You can use any tool, application or method to copy this file from localhost to Ubuntu Linux server. I used WinSCP tool to copy this file from machine where i have downloaded the package to the Ubuntu Linux server. Make sure that there should be connectivity between both machine.
If you have not installed WinSCP yet, download and install it on your PC. Launch WinSCP tool and make a connection to Ubuntu server. I have explained about WinSCP in my last articles, you can follow it to get more details. Once you established the connection, WinSCP will look like below image.
Now we just need to drag the downloaded debian packages from left side pane and drop it to right side pane to copy it to Ubuntu Linux server. Files are copied now and we can see them in both side panes.
You can see SQL Tools packages are copied to location \home\techyaz\ in above screenshot. Now we can connect to Ubuntu server and validate whether files are copied there or not.
Connect to Ubuntu server and check the files. You can run ls -lrt to check the files. Once packages will be copied to ubuntu server, next step is to first install msodbcsql package. Run below command to start the installation.
#Install msodbcsql package sudo dpkg -i msodbcsql_22.214.171.124-1_amd64.deb
Here we will use dpkg package management system for installation because SQL Tools are debian packages for Ubuntu servers. We can see below dependencies error while executing msodbc package. Now our next step is to fix these dependency issues and then kick off the installation again.
We can see msodbcsql package depends on unixODBC package so first we need to download, move and install unixODBC package on Ubuntu server.
Resolving dependencies are painful job because every package has some dependencies and you need to download and install all such packages manually if you don’t have internet connection on Ubuntu server. If your Ubuntu server has internet connection, all dependencies will be installed using online repository.
Now let’s download and move unixODBC package to Ubuntu server. We can download all required debian packages from attached link. We can see unixODBC package has been copied to the server now in below image.
Install this package now.
#Install unixODBC Package. sudo dpkg -i unixodbc_2.3.1-4.1_amd64.deb
We can see this package has another dependency error. That means UnixODBC package is dependent on given packages i.e. libodbc1 & odbcinst1debian2.
When i downloaded libodbc1 and tried to install it, this package failed because of another dependency.
We can see the dependent package in above image. I downloaded package libltdl7 and installed on Ubuntu server. libltdl7 package got installed successfully without any dependency error.
Once libltdl7 package will be installed, next step is to install all dependencies in reverse order. Here we will install libodbc1 then unixodbc followed by msodbcsql package.
We have seen, there were two dependencies to install unixODBC package. One libodbc1 has been installed. Please perform similar exercise to install another dependency odbcinst1debian2. Once both packages will be installed, go ahead and install unixodbc in order to install msodbcsql package.
If you want to check all dependencies for these packages, you can get it by running below command.
#Check dependencies of both packages. dpkg -I msodbcsql_126.96.36.199-1_amd64.deb | grep "Depends:" dpkg -I mssql-tools_188.8.131.52-1_amd64.deb | grep "Depends:"
If you have internet connection on your Ubuntu server then this task will be very easy to perform. You just need to execute below command to install unixodbc package.
#Install unixodbc on Ubuntu if server is connected to Internet. sudo apt-get -f install unixodbc
SQL Tools Installation
We have resolved all dependencies errors in above section. Now we will install SQL Tools to establish database connection to SQL Server instance from ubuntu server. Run below command to install the msodbcsql package again post resolving dependencies.
#Install msodbcsql Package sudo dpkg -i msodbcsql_184.108.40.206-1_amd64.deb
Once you will execute above command, you will get below screen to accept the license terms. Choose Yes and press enter button to proceed.
Once you press enter, package execution will start. You can see msodbcsql package is installed successfully now.
Next we will install another package mssql-tools now. Run below command to start the installation.
#Install mssql-tools Package sudo dpkg -i mssql-tools_220.127.116.11-1_amd64.deb
Again this package will ask you to accept the license terms just like msodbcsql package. Choose yes and press enter to proceed.
You cans see mssql-tools package is installed in below image.
Final step is to set the path environment variables. Run below command to set the path environment variables. Ubuntu will not be able to recognize sqlcmd utility unless you set the path environment variable. You can see that in below screenshot. Ubuntu is able to recognize sqlcmd utility once we set the path environment variables.
#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
Now connect to SQL Server instance using sqlcmd and run a command to validate this installation. I have checked the SQL Server version installed on ubuntu server.
We get above details that SQL Server 2017 is installed on this Ubuntu server by executing sqlcmd utility. Now we have done with SQL Tools installation on Ubuntu server. Go ahead and connect to your Ubuntu server using SQL Tools.
Read more about SQL Server on RedHat Linux:
- How to Create a Virtual Machine.
- Installing RedHat Linux 7.3 on a virtual machine.
- Install SQL Server 2017 on RedHat Linux – Offline Installation.
- How to Install SQL Tools on RedHat Linux – Offline Installation.
- SQL Server Agent Installation on RedHat Linux – Offline Installation.
Latest posts by Manvendra Deo Singh (see all)
- Understanding Hybrid Buffer Pool in SQL Server - December 30, 2018
- Fix:VIEW SERVER STATE permission was denied on object ‘server’, database ‘master’ - August 30, 2018
- SQL Server Error 5184: Cannot use file ‘I:\Path\Techyaz.mdf’ for clustered server - August 29, 2018