By:Manvendra Singh || Related Tips:More >SQL Server on linux

Problem

I explained how to install SQL Server vNext on Ubuntu in my last tip and in this tip we will look at how to install SQL Server tools on the Ubuntu server.

Solution

As I discussed in my last couple of articles , SQL Server vNext does not install sqlcmd and BCP utility with the SQL Server installation on Red Hat Linux and Ubuntu servers, but we need the sqlcmd utility to make a database connection from the Linux based servers. We will walk through the steps to install these tools on the Ubuntu server.

SQL Server Tools Installation on Ubuntu Server

Before going forward, you need to have an Ubuntu server with SQL Server vNext installed on that machine. I followed the step by step method of Microsoft's online documentation to understand this installation. Let's start the SQL Server tools installation on Ubuntu.

Step 1: First connect to the target Ubuntu server on which you have installed SQL Server vNext. You can directly connect to the server by logging in to the server to do this exercise or you can use PuTTY, a third party tool, to make a server connection. I used PuTTY to login on this server. I launched PuTTY and entered the IP address of the Ubuntu server and then clicked the open button. A black screen known as the PuTTY terminal will appear asking you to enter the login information to connect to the target server. I entered the login name as manvendra followed by its password to make a successful connection as shown below.


Install SQL Server Tools to Establish a Database Connection from an Ubuntu Serve ...

Once you would have established a successful connection, you can see the version of the Ubuntu server as shown in the above screenshot.

Step 2: You can see that I made a successful connection to this Ubuntu server where I installed SQL Server in mylast tip. Now let's check and verify the SQL Server installation on this machine. Run the below command to check the mssql-server service.

#check the status of mssql-server service.
systemctl status mssql-server
Install SQL Server Tools to Establish a Database Connection from an Ubuntu Serve ...

We can see the service status is showing enabled and active (running) which is highlighted in green. This means SQL Server is installed and running fine on this server.

Step 3: Next we will install the MSSQL tools on this server. The first step of installation is to import the public repository GPG keys as per Microsoft's documentation, so we will run the below command to import the GPG keys. GPG keys also provide cryptographic privacy and authentication.

#import the public repository GPG keys
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -

You can see that command has been executed successfully in the below screenshot.


Install SQL Server Tools to Establish a Database Connection from an Ubuntu Serve ...

Step 4: Now we will run a curl command to register the Microsoft Ubuntu repository. This repository will be used to install the MSSQL tools on this machine. The downloaded file will be saved in location /etc/apt/sources.list.d/ as mentioned in the command line.

#Download Ubuntu installation configuration file.
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list

We can see the progress, time and details of the downloaded configuration file in the below picture.


Install SQL Server Tools to Establish a Database Connection from an Ubuntu Serve ...

Now we can check the location /etc/apt/sources.list.d/ to verify whether the above file is saved in this location. Run ls -lrt command to display all of the files present in that folder.

#list all files/folders inside the /etc/apt/sources.list.d/ folder.
ls -lrt /etc/apt/sources.list.d/
Install SQL Server Tools to Establish a Database Connection from an Ubuntu Serve ...

You can see our target file msprod.list file is there in this location in the above picture.

Step 5: Now our next step is to install MSSQL tools on this box with the help of this package. But before going ahead, we will run the below command to update the sources list on this Ubuntu server.

#update the sources list
sudo apt-get update
Install SQL Server Tools to Establish a Database Connection from an Ubuntu Serve ...

Once you execute this command, a series of updates will be displayed on your screen. This execution will also display the size of updates for any respective packages.


Install SQL Server Tools to Establish a Database Connection from an Ubuntu Serve ...

Step 6: Once the above command executes successfully we will run the below command to install the MSSQL tools on this machine.

#Install MSSQL tools
sudo apt-get install mssql-tools
Install SQL Server Tools to Establish a Database Connection from an Ubuntu Serve ...

Once execution starts, it will read the package list followed by checking dependencies. It will display the name of the target packages which will be installed along with this installation. Now it will ask you to choose yes or no to proceed with the installation. Type y to choose yes. Once you press enter after typing y, the download process for all required packages will start as shown in the below picture.


Install SQL Server Tools to Establish a Database Connection from an Ubuntu Serve ...

You can see the progress for a particular package which is in process as shown below.


Install SQL Server Tools to Establish a Database Connection from an Ubuntu Serve ...

Every package will ask you to enter YES to accept the license terms during installation as shown in the below screenshot. You will get the below screen to accept the license terms. Choose YES and press enter to proceed.


Install SQL Server Tools to Establish a Database Connection from an Ubuntu Serve ...

Once you press enter, again execution will be resumed in the PuTTY terminal.


Install SQL Server Tools to Establish a Database Connection from an Ubuntu Serve ...

The next window is to accept the license terms for the msodbcsql package similar to the above screenshot.


Install SQL Server Tools to Establish a Database Connection from an Ubuntu Serve ...

Again processing, things will resume in the PuTTY terminal as shown in the below picture.


Install SQL Server Tools to Establish a Database Connection from an Ubuntu Serve ...

Let them proceed as shown in the above picture. When done, execution will stop and the MSSQL tools will be installed on your Ubuntu server.


Install SQL Server Tools to Establish a Database Connection from an Ubuntu Serve ...

Step 7: Now we will check and verify whether sqlcmd utility is installed on this machine. Type sqlcmd and press enter to check the details of this utility.

#check sqlcmd utility.
sqlcmd

We can see that sqlcmd is recognized by Ubuntu and the output of this command is shows that sqlcmd is installed and ready to use.


Install SQL Server Tools to Establish a Database Connection from an Ubuntu Serve ...

Next we will validate sqlcmd by making a database connection from Ubuntu server on the PuTTY terminal. Run the below command to connect to database engine from the Ubuntu server.

#Run sqlcmd to make database connection.
#You need to pass server name/IP address with -S, user name with -U. Enter the password of sa account once you get the Password prompt.
sqlcmd -S192.168.209.129 -Usa Once you execute the above

本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统

主题: SQLUbuntuLinuxSQL Server
分页:12
转载请注明
本文标题:Install SQL Server Tools to Establish a Database Connection from an Ubuntu Serve ...
本站链接:http://www.codesec.net/view/534023.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(linux) | 评论(0) | 阅读(36)