By: Manvendra Singh | Updated: 2018-04-11 | Comments | Related: More > SQL Server on Linux
I have shown how to uninstall SQL Server 2017 from an Ubuntu server in a past tip and in this tip I will show how to uninstall SQL tools (sqlcmd and bcp) on an Ubuntu server.
As you may know, Microsoft has extended its SQL Server support to Linux based operating systems starting with SQL Server 2017. We have to install SQL Server and SQL Tools (sqlcmd and bcp) separately using two different install packages. SQL Tools contains command-line utilities, Microsoft ODBC drivers, and their dependencies. The package name of the SQL Tools is mssql-tools. This package contains sqlcmd and bcp utilities as well. We use the sqlcmd utility to connect to a SQL Server instance and execute queries, where the bcp utility is used for bulk import and export operations.
If we need to uninstall these tools from any Linux system, we need to uninstall it separately from SQL Server. The uninstall of SQL Server 2017 will not remove SQL tools from your Linux database server.
I have also written multiple tips on how to install SQL Server 2017 on different Linux flavors. Have a look at the “Next Steps” section to access all of those tips.
In this tip we will cover the steps to remove the sqlcmd and bcp utilities from an Ubuntu Linux machine.
Uninstall SQL Server 2017 Running on Ubuntu
I have installed SQL Server 2017 along with SQL Tools (sqlcmd and bcp) on this machine for some project work. Now, I have to uninstall it and clean the Ubuntu machine. I have already uninstalled SQL Server 2017 in my last tip and now we will cover how to remove SQL Tools.
You might have a requirement to remove only SQL Tools from your system. It may not be mandatory to remove your SQL Server instance running on the Linux sever before removing SQL Tools. But, generally we remove SQL Tools as part of the full SQL Server removal from any machine. If you have already uninstalled SQL Server from your Ubuntu server then the next step is to remove SQL Tools to clean your machine. The first step is to connect to your Linux database server by entering your login name and password. Once connected to your Ubuntu Linux server, then we can go ahead and verify whether SQL Tools are installed or your machine or not by executing the below command.
#Type sqlcmd on your Linux terminal and press enter sqlcmd
By trying to run sqlcmd command on your Linux terminal, we can see if your Linux system recognizes this command which means SQL Tools are installed. You can see this in the below screenshot that this utility has been recognized by the Ubuntu Linux server.
Now you can check whether a SQL Server instance is installed on this machine or if it has already been removed. You can check the SQL Server service by running the below command.
#Run below command to check SQL Server Instance running on this Linux server. systemctl status mssql-server
You can see there is no SQL Server instance on this server in the below screenshot.
Our next step would be to remove SQL Tools (sqlcmd and bcp) from this server. We will use the apt-get command to remove these utilities. The apt-get is the command-line tool for working with core libraries to handle the installation and removal of software on Linux distributions like Ubuntu, Debian, etc.
Here we will use the apt-get remove command to perform this uninstall on this machine. Run the below commands to remove the SQL Tools from your Ubuntu server.
#Run below command to remove SQL Tools sudo apt-get remove mssql-tools
This command will read the package and show you what components will be removed. This command will ask you to enter Y to proceed with the removal and enter n to quit this uninstall. I entered Y to proceed. You can see the SQL Tools have been uninstalled from this server in the below image.
Now, we can validate whether SQL Tools (sqlcmd and bcp) have been uninstalled from this machine. We can get this by running sqlcmd command from your Linux terminal as we did in Step 1. We can see that Ubuntu does not recognize this command anymore and says, “No such file or directory”.
Another way to validate this uninstall is by removing the SQL Tools package again by executing the same commands we ran in Step 3. You can see the command apt-get is not able to locate the SQL Tools package on the server because we have already uninstalled it.
Once the tools are uninstalled, you will not be able to use sqlcmd and bcp utilities. You will not be able to connect to SQL Server from local Ubuntu server since you need sqlcmd to connect to the database from the local server to perform any query executions.
- If you need to install SQL Server on your database server again, go ahead and install SQL Server on Ubuntu.
- Read more articles on SQL Server on Linux.
- Explore more knowledge on SQL Server Database Administration Tips.
Last Updated: 2018-04-11
About the author
View all my tips