APT/DPKG 已损坏 - 无法删除 mysql-server-core-5.5

APT/DPKG 已损坏 - 无法删除 mysql-server-core-5.5

我想完全删除服务器上与 mysql 相关的所有软件包。但我似乎无法完成这项任务。APT 似乎无法理解服务器上未安装 mysql-server。是否可以手动告诉 apt 软件包已被删除?

╭─root@home /etc/apt
╰─➤  apt-get remove mysql-server-core-5.5                                                                              
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
mysql-server-5.5 : Depends: mysql-client-5.5 (>= 5.5.54-0+deb8u1) but it is not going to be installed
                Depends: mysql-server-core-5.5 (>= 5.5.54-0+deb8u1) but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a  solution).

我也尝试过“清除”

╭─root@home /etc/apt
╰─➤  apt-get purge mysql-server-core-5.5                                                                             100 ↵
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 mysql-server-5.5 : Depends: mysql-client-5.5 (>= 5.5.54-0+deb8u1) but it is not going to be installed
                    Depends: mysql-server-core-5.5 (>= 5.5.54-0+deb8u1) but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

运行 apt-get -f install 不能解决任何问题

dpkg: error processing package mysql-server-5.5 (--configure):
 subprocess installed post-installation script returned error exit status 6
Processing triggers for libc-bin (2.19-18+deb8u7) ...
Errors were encountered while processing:
 mysql-server-5.5
E: Sub-process /usr/bin/dpkg returned an error code (1)

运行 apt-get install mysql-server-5.5 --reinstall 也不起作用。

╭─root@home /etc/apt
╰─➤  apt-get install mysql-server-5.5 --reinstall                                                                    100 ↵
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
E: Internal Error, No file name for mysql-server-5.5:amd64

尝试使用 dpkg --purge --force-all mysql-community-server mysql-server-5.5 mysql-server-core-5.5 手动删除是没用的

╭─root@home /etc/apt
╰─➤  dpkg --purge --force-all mysql-community-server mysql-server-5.5 mysql-server-core-5.5                            1 ↵
(Reading database ... 40739 files and directories currently installed.)
Removing mysql-community-server (5.7.17-1debian8) ...
Purging configuration files for mysql-community-server (5.7.17-1debian8) ...
................
dpkg: error processing package mysql-community-server (--purge):
 subprocess installed post-removal script returned error exit status 1
Removing mysql-server-5.5 (5.5.54-0+deb8u1) ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
dpkg: error processing package mysql-server-5.5 (--purge):
 subprocess installed pre-removal script returned error exit status 5
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
Failed to start mysql.service: Unit mysql.service failed to load: No such file or directory.
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 6
dpkg: warning: ignoring request to remove mysql-server-core-5.5 which isn't installed
Errors were encountered while processing:
 mysql-community-server
 mysql-server-5.5

逐个删除软件包也不起作用,系统提示“对话框”要求我为 mysql-server 设置 root 密码。

apt-get 删除 mysql 服务器 apt-get 删除 mysql 客户端 apt-get 删除 mysql 服务器核心

我会尽力按照您的意愿更新这个问题,但我现在正为此而烦恼。我几乎要重新安装整个服务器了。

答案1

从显示的消息来看,由于依赖关系,apt-get 停止,这是正确的行为。否则依赖该包的模块将停止工作。

正确的方法是阅读有关依赖于它的模块的消息,然后按顺序逐个删除它们,直到全部删除。

从消息来看, mysql-server-coremysql-server 需要。因此您必须按顺序进行删除。

sudo apt-get purge mysql-server
sudo apt-get purge mysql-client
sudo apt-get purge mysql-common
# I think when you uninstall mysql-server, it will also remove the core

最好的方法始终是用来dpkg -l | grep mysql检查已安装的相关包。

请尝试应用所述答案在这个问题中如果以上所有方法均失败。尽管如此,一些问题还是由指向包含旧的/有缺陷的安装脚本的过时的 debian/ubuntu 存储库引起的,但这种情况很少见。

相关内容