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/、ダウンロードをスキップして 2 番目の手順から直接開始できる場合があります。

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

関連情報