Debian

在 Debian 9 Stretch 上安裝 mysql-server 時出錯(依賴問題)

  • April 2, 2021

使用 Debian 9.5,全新安裝。我想安裝mysql-server,但遇到了依賴問題。

sudo apt-get install mysql-server
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:
mysql-server : Depends: default-mysql-server but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

apt-get install mysql-server default-mysql-server
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:
default-mysql-server : Depends: mariadb-server-10.1 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

sudo apt-get install mysql-server default-mysql-server mariadb-server-10.1
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:
mariadb-server-10.1 : Depends: libdbi-perl but it is not going to be installed
                      Recommends: libhtml-template-perl but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

sudo apt-get install mysql-server default-mysql-server mariadb-server-10.1 libhtml-template-perl
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:
libhtml-template-perl : Depends: libcgi-pm-perl but it is not going to be installed or
                                 perl (< 5.19) but 5.26.2-7 is to be installed
mariadb-server-10.1 : Depends: libdbi-perl but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

sudo apt-get install mysql-server default-mysql-server mariadb-server-10.1 libdbi-perl
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:
libdbi-perl : Depends: perlapi-5.24.1
E: Unable to correct problems, you have held broken packages.

編輯1 apt-cache policy::

apt-cache policy
Package files:
100 /var/lib/dpkg/status
    release a=now
500 http://security.debian.org/debian-security stretch/updates/contrib amd64 Packages
    release v=9,o=Debian,a=stable,n=stretch,l=Debian-Security,c=contrib,b=amd64
    origin security.debian.org
500 http://security.debian.org/debian-security stretch/updates/main amd64 Packages
    release v=9,o=Debian,a=stable,n=stretch,l=Debian-Security,c=main,b=amd64
    origin security.debian.org
500 http://deb.debian.org/debian stretch-updates/main amd64 Packages
    release o=Debian,a=stable-updates,n=stretch-updates,l=Debian,c=main,b=amd64
    origin deb.debian.org
500 http://deb.debian.org/debian stretch/main amd64 Packages
    release v=9.5,o=Debian,a=stable,n=stretch,l=Debian,c=main,b=amd64
    origin deb.debian.org
Pinned packages:

apt policy perl perl-base編輯2 ::

apt policy perl perl-base
perl:
 Installed: 5.26.2-7
 Candidate: 5.26.2-7
 Version table:
*** 5.26.2-7 100
       100 /var/lib/dpkg/status
    5.24.1-3+deb9u4 500
       500 http://deb.debian.org/debian stretch/main amd64 Packages
       500 http://security.debian.org/debian-security stretch/updates/main amd64 Packages
perl-base:
 Installed: 5.26.2-7
 Candidate: 5.26.2-7
 Version table:
*** 5.26.2-7 100
       100 /var/lib/dpkg/status
    5.24.1-3+deb9u4 500
       500 http://deb.debian.org/debian stretch/main amd64 Packages
       500 http://security.debian.org/debian-security stretch/updates/main amd64 Packages

如何解決這些依賴問題?

如您的apt policy perl perl-base輸出所示,並由jordanm指出,您的系統具有 Perl 的 Buster 版本,而不是 Debian 9 版本。所以你的系統並不是真正的 Debian 9.5 的“全新安裝”;並且由於 Perl 是 Debian 設置中如此重要的組件,因此可能還有許多其他軟體包已升級到 Buster 版本。

這種 Perl 不匹配是您無法安裝 MySQL 軟體包的原因。

我假設這是最近安裝的,因此您沒有太多投資;因此,jordanm建議重新安裝可能是這種情況下的最佳解決方案。Debian 9 和 Buster 有很大的不同,因此回滾可能會變得相當複雜,尤其是在您升級 Perl 之後。刪除mc肯定是不夠的。

以後不要混用穩定版和測試版。如果您遇到阻止您使用包的錯誤,請送出錯誤 ( reportbug mc);如果它足夠嚴重,它可能有資格獲得穩定的更新。您也可以要求反向移植;這將為您提供目前的 Buster 版本mc,為 Debian 9 重建。

引用自:https://unix.stackexchange.com/questions/470903