mysql-common 无法卸载

Aze*_*rah 3 mysql package-management uninstall apt dpkg

我试图完全卸载mysql以稍后重新安装,卸载所有与mysql相关的包后,mysql-common似乎仍处于损坏状态。

$ sudo dpkg -l | grep mysql
pc  mysql-common                                  5.6.28-0ubuntu0.15.10.1                      all          MySQL database common files, e.g. /etc/mysql/my.cnf
Run Code Online (Sandbox Code Playgroud)

但是运行 apt-get remove

$ sudo apt-get remove mysql-common
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package 'mysql-common' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 36 not upgraded.
Run Code Online (Sandbox Code Playgroud)

或者使用 --purge

$ sudo apt-get remove --purge mysql-common
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  mysql-common*
0 upgraded, 0 newly installed, 1 to remove and 36 not upgraded.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 199090 files and directories currently installed.)
Removing mysql-common (5.6.28-0ubuntu0.15.10.1) ...
Purging configuration files for mysql-common (5.6.28-0ubuntu0.15.10.1) ...
update-alternatives: error: no alternatives for my.cnf
dpkg: error processing package mysql-common (--purge):
 subprocess installed post-removal script returned error exit status 2
Errors were encountered while processing:
 mysql-common
E: Sub-process /usr/bin/dpkg returned an error code (1)
Run Code Online (Sandbox Code Playgroud)

此外,我已经删除了所有与 mysql 相关的目录和文件。

我怎样才能摆脱这个挥之不去的破损包裹?

Jos*_*Jos 5

如果某些依赖项消失了,或者某些配置文件由于某种原因被删除,则某些软件包将无法卸载。您最终会得到一个既没有完全安装也没有完全卸载的软件包。

在这种情况下,解决方案是sudo apt-get install打包。如有必要,请执行sudo apt-get install --reinstall [package]。丢失的文件将被添加到系统中,并且任何丢失的依赖项都会即时安装。然后可以按照通常的方式完全卸载软件包:sudo apt-get remove [package].

如果apt-get因为其他(依赖)问题拒绝重新安装包,则只能使用apt-get下载包dpkg直接安装:

apt-get download mysql-common
sudo dpkg -i mysql-common_*.deb
sudo apt-get install -f
Run Code Online (Sandbox Code Playgroud)

有时您可以跳过下载,因为 Apt 倾向于保留以前下载和安装的软件包的存档,/var/cache/apt/archives/因此您可以直接从第二步开始:

sudo dpkg -i /var/cache/apt/archives/mysql-common_*.deb
Run Code Online (Sandbox Code Playgroud)