By: Manvendra Singh | Updated: 2017-08-09 | Comments | SQL Server on Linux
In a previous tip, I showed how to install SQL Server vNext on SUSE Linux. In this tip, we will show how to install MSSQL tools to establish a database connection to SQL Server on SUSE Linux.
As discussed in my last couple of tips, SQL Server vNext does not install the sqlcmd or BCP during the SQL Server installation on Linux servers. We need sqlcmd to make a database connection on the Linux server, so I will show the installation of these tools to make database connections on the SUSE Linux server.
MSSQL Tools Installation on SUSE Linux
Before going ahead, you need to have SUSE Linux with SQL Server vNext installed on that machine.
First connect to the target SUSE Linux server on which you have installed SQL Server vNext. You can directly connect to the server or you can use PuTTY a third party tool to make a server connection. I used PuTTY to login to this server. I launched PuTTY and entered the IP address of the SUSE Linux server and then clicked on 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 followed by the password to make a connection as shown below.
You can see that I connected to this SUSE Linux server. 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
We can see the service status is enabled and active (running) which is highlighted in green. This means SQL Server is installed and running fine on this server.
Next we will install the MSSQL tools on this server. Before going ahead we can verify whether the mssql tools are installed on this machine or not. You can type sqlcmd and press enter, if you will get details about this utility that means this tool is already on the server. I did this and you can see sqlcmd is not recognized by SUSE Linux, so the next step is to install it on this machine.
We need to add the SQL Server repository to zypper. This repository will be used to install MSSQL tools on this machine, so to add the SQL Server repository to zypper run the below command.
#Add repository to Zypper. sudo zypper addrepo -fc https://packages.microsoft.com/config/sles/12/prod.repo
You can see that command has executed successfully. Now execute the below command to refresh the keys.
sudo zypper --gpg-auto-import-keys refresh
Next check the list of repositories by running the below zypper command.
#Get the list of repositories zypper lr
Now our next step is to install the MSSQL tools with the unixODBC developer package on this box by using this zypper command.
#Install MSSQL tools sudo zypper install mssql-tools unixODBC-devel
Once execution starts, it will read the package list followed by checking the 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 y or n to proceed with the installation. Type y to choose yes. Once you press enter the download process for all required packages will be started as shown below.
You can see the progress bar for the packages which are in process to download. Every package will ask you to enter YES to accept the license terms during installation as shown below. You will get the below screen to accept the license terms. Choose YES and press enter to proceed.
Once you press enter, execution will resume in the PuTTY terminal. Once installation is done for this package, the next window will ask you to accept the license terms again for the next package similar to the above screenshot.
We can see mssql tools have been installed on this machine as shown in the below image. Now we will check and validate this.
Now we will check and verify whether the sqlcmd utility is installed to access SQL Server on this machine. Type sqlcmd and press enter to check the details of this utility.
#check sqlcmd utility. sqlcmd
We can see that sqlcmd command is recognized by the SUSE Linux server and the output of this command shows that sqlcmd is installed and ready for use.
Next we will validate sqlcmd by making a database connection to the SUSE Linux server. Run the below command to connect to the database engine from the SUSE Linux 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.130 -Usa
Once you execute the command, a SQL Server prompt will appear with cursor 1>.
I executed "SELECT @@VERSION" to check the version of SQL Server which is shown below.
Below I will run this code in sqlcmd to create a new database named "Manvendra" and then query sysdatabases to list all of the databases.
#Create a db named Manvendra CREATE DATABASE Manvendra #Check database name in sysdatabases system table. #Run this command on sqlcmd prompt only. SELECT name from sysdatabases GO
We can see there are 5 databases including database "Manvendra".
We have validated that we can connect to SQL Server vNext database engine using sqlcmd on the SUSE Linux server.
- Go ahead and make database connections on SUSE Linux server and get more exposure on this new SQL Server offering.
- Explore more knowledge on SQL Server on Linux Tips
Last Updated: 2017-08-09
About the author
View all my tips