在 Debian 9 Stretch 上安装 mysql-server 时出错(依赖问题)

在 Debian 9 Stretch 上安装 mysql-server 时出错(依赖问题)

使用 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:

编辑2 apt policy perl perl-base::

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

我该如何解决这些依赖性问题?

答案1

如您的输出所示apt policy perl perl-base,并且指出经过约旦,您的系统有 Buster 版本的 Perl,而不是 Debian 9 版本。因此,您的系统并不是真正“全新安装”的 Debian 9.5;而是真正的 Debian 9.5。由于 Perl 是 Debian 设置中如此重要的组件,因此可能还有许多其他软件包已升级到 Buster 版本。

Perl 不匹配是您无法安装 MySQL 软件包的原因。

我假设这是最近安装的,因此您没有对其投入太多;所以乔丹的建议重新安装在这种情况下可能是最好的解决方案。 Debian 9 和 Buster 有很大分歧,因此回滚可能会变得相当复杂,特别是在您升级了 Perl 后。删除mc肯定是不够的。

将来,不要将稳定版和测试版混在一起。如果您遇到阻止您使用软件包的错误,请提交错误 ( reportbug mc);如果问题足够严重,则有资格获得稳定更新。您还可以要求向后移植;这将为您提供当前的 Buster 版本mc,为 Debian 9 重建。

答案2

我根据接受的解决方案成功执行了以下命令:

wget http://ftp.debian.org/debian/pool/main/p/perl/perl-base_5.24.1-3+deb9u4_amd64.deb
sudo dpkg -i perl-base*deb
    dpkg: warning: downgrading perl-base from 5.26.2-7 to 5.24.1-3+deb9u4
    (Reading database ... 38749 files and directories currently installed.)
    Preparing to unpack perl-base_5.24.1-3+deb9u4_amd64.deb ...
    Unpacking perl-base (5.24.1-3+deb9u4) over (5.26.2-7) ...
    Setting up perl-base (5.24.1-3+deb9u4) ...
    Processing triggers for man-db (2.7.6.1-2) ...
sudo apt-get install mysql-server
sudo apt --fix-broken install
sudo apt autoremove
sudo apt-get install mysql-server
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    mysql-server is already the newest version (5.5.9999+default).
    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

结果:

dpkg -l perl-base
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                                  Version                         Architecture                    Description
+++-=====================================================-===============================-===============================-===============================================================================================================
ii  perl-base                                             5.24.1-3+deb9u4                 amd64                           minimal Perl system


dpkg -l mysql-server
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                                  Version                         Architecture                    Description
+++-=====================================================-===============================-===============================-===============================================================================================================
ii  mysql-server                                          5.5.9999+default                amd64                           MySQL database server binaries and system database setup [transitional]

答案3

sudo apt install mysql-server 读取软件包列表...完成 构建依赖关系树
读取状态信息...完成 某些软件包无法安装。这可能意味着您请求了一种不可能的情况,或者如果您使用的是不稳定的发行版,某些所需的软件包尚未创建或已移出传入。以下信息可能有助于解决问题:

以下软件包具有未满足的依赖关系: mysql-server :依赖: mysql-server-8.0 但不会安装 E:无法纠正问题,您持有损坏的软件包。 raja@raja-latitudee6400:~$ mysql 服务器默认 mysql 服务器 bash: mysql 服务器: 找不到命令

相关内容