mysql-common無法卸載

mysql-common無法卸載

我試圖完全卸載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/以便您可以直接從第二步開始:

sudo dpkg -i /var/cache/apt/archives/mysql-common_*.deb

相關內容