我正在尝试完全卸载 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
但运行 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.
或者使用 --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)
此外,我删除了所有与 mysql 相关的目录和文件。
我怎样才能摆脱这个挥之不去的破损包裹?
答案1
如果某些依赖项消失,或者由于某种原因删除了某些配置文件,则某些软件包无法卸载。最终您将得到一个未完全安装或未完全卸载的软件包。
在这种情况下,解决方案是卸载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
有时你可以跳过下载,因为 Apt 倾向于保留以前下载和安装的软件包的存档,/var/cache/apt/archives/
因此你可以直接从第 2 步开始:
sudo dpkg -i /var/cache/apt/archives/mysql-common_*.deb