20

I installed the sqlserver based on the Microsoft Documentation. The following commands are executed correctly.

wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -

sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2017.list)"

sudo apt-get update
sudo apt-get install -y mssql-server

sudo /opt/mssql/bin/mssql-conf setup

systemctl status mssql-server

status of sql server

But when I try to install the SQL Server command-line tools,the following error occurs.

sudo apt-get install mssql-tools unixodbc-dev


Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 mssql-tools : Depends: msodbcsql17 (>= 17.3.0.0) but it is not going 
 to be installed
           Depends: msodbcsql17 (< 17.4.0.0) but it is not going to be 
  installed
 E: Unable to correct problems, you have held broken packages.

My operation system is Linux Ubuntu 18.04.1 LTS

Liso
  • 15,677

5 Answers5

24

After searching around, I have found the requested package, it is located on Microsoft Ubuntu 18.04 repository, in order to install the package you have to add the repo first.

This will install msodbcsql17 that correspond to Ubuntu 18.04, open up terminal and run:

curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
echo "deb [arch=amd64] https://packages.microsoft.com/ubuntu/18.04/prod bionic main" | sudo tee /etc/apt/sources.list.d/mssql-release.list
sudo apt update
sudo apt install msodbcsql17

Here is an update for 20.04:

curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
echo "deb [arch=amd64] https://packages.microsoft.com/ubuntu/20.04/prod focal main" | tee /etc/apt/sources.list.d/mssql-release.list
sudo apt update
sudo apt-get install -y msodbcsql17
Liso
  • 15,677
11

I had the same issue but above solutions didn't workout for me. So here's how I solved this problem.

sudo apt-get install -y libodbc1
sudo apt update
sudo apt install unixodbc

Following commands from microsoft docs

sudo su
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -

curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list > /etc/apt/sources.list.d/mssql-release.list

exit
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql17
1

I had similar problem but not same. In my case error was

can't open lib '/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.2.so.0.1' : file not found

I was uninstalling msodbc and then reinstalling it. After some research, I needed to uninstall msodbc17, and then do re-install.

sudo apt-get remove msodbcsql17
sudo apt-get install msodbcsql17 -y
damadam
  • 2,873
1

It was not enough in my case, and I was made to execute the following commands: sudo apt install libodbc1 sudo apt install unixodbc

0

Update for 20.04 from the accepted answer

curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
echo "deb [arch=amd64] https://packages.microsoft.com/ubuntu/20.04/prod focal main" | tee /etc/apt/sources.list.d/mssql-release.list
apt update
$APT msodbcsql17