无法在 Ubuntu 18.04 上安装 msodbcsql17

无法在 Ubuntu 18.04 上安装 msodbcsql17

我根据Microsoft 文档以下命令执行正确。

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

SQL 服务器的状态

但是当我尝试安装 SQL Server 命令行工具时出现以下错误。

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.

我的操作系统是 Linux Ubuntu 18.04.1 LTS

答案1

经过一番搜索,我找到了所需的包,它位于Microsoft Ubuntu 18.04 存储库,为了安装该包,您必须先添加 repo。

这将安装msodbcsql17与 Ubuntu 18.04 相对应的版本,打开终端并运行:

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

以下是 的更新内容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

答案2

我遇到了同样的问题,但上述解决方案对我没有用。下面是我解决这个问题的方法。

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

按照以下命令微软文档

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

答案3

我遇到了类似的问题,但不是相同的。在我的例子中,错误是

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

我正在卸载msodbc然后重新安装它。经过一番研究,我需要卸载msodbc17,然后重新安装。

sudo apt-get remove msodbcsql17
sudo apt-get install msodbcsql17 -y

答案4

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
apt update
$APT msodbcsql17

相关内容