dpkg:phpmyadminパッケージの処理中にエラーが発生しました。

dpkg:phpmyadminパッケージの処理中にエラーが発生しました。

apt upgradeDebian サーバーで操作を実行すると、次のエラーが発生します。

Preparing to unpack .../phpmyadmin_4%3a4.6.6-4+deb9u1_all.deb ...
Determining localhost credentials from /etc/mysql/debian.cnf: succeeded.
dpkg: warning: subprocess old pre-removal script returned error exit status 10
dpkg: trying script from the new package instead ...
Determining localhost credentials from /etc/mysql/debian.cnf: succeeded.
dpkg: error processing archive /var/cache/apt/archives/phpmyadmin_4%3a4.6.6-4+deb9u1_all.deb (--unpack):
 subprocess new pre-removal script returned error exit status 10
dbconfig-common: flushing administrative password
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 10
Preparing to unpack .../libgssdp-1.0-3_1.0.1-1+deb9u1_amd64.deb ...
Unpacking libgssdp-1.0-3:amd64 (1.0.1-1+deb9u1) over (1.0.1-1) ...
Preparing to unpack .../libgupnp-1.0-4_1.0.1-1+deb9u1_amd64.deb ...
Unpacking libgupnp-1.0-4:amd64 (1.0.1-1+deb9u1) over (1.0.1-1) ...
Preparing to unpack .../libpq5_9.6.19-0+deb9u1_amd64.deb ...
Unpacking libpq5:amd64 (9.6.19-0+deb9u1) over (9.6.17-0+deb9u1) ...
Errors were encountered while processing:

/var/cache/apt/archives/phpmyadmin_4%3a4.6.6-4+deb9u1_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

phpmyadminを削除しようとしましたが、次のエラーが発生しました。

The following packages will be REMOVED:
  phpmyadmin
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
6 not fully installed or removed.
After this operation, 24.8 MB disk space will be freed.
Do you want to continue? [Y/n]
dpkg: error processing package phpmyadmin (--remove):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting a removal
Errors were encountered while processing:
 phpmyadmin
E: Sub-process /usr/bin/dpkg returned an error code (1)

私もそうでした:

apt-get clean
apt-get update && apt-get upgrade
dpkg --configure -a
apt-get -f install

しかし、何も動作しません。

答え1

端末を開き、次のように入力します。

sudo mv /var/lib/dpkg/info/phpmyadmin.* /tmp/
sudo dpkg --remove --force-remove-reinstreq phpmyadmin
sudo apt remove phpmyadmin
sudo apt autoremove
sudo apt autoclean

関連情報