1

I have been trying to remove MySQL from my node, but it fails removal. I have tried remove, purge, dpkg --force-all, to no effect. Suggestions?

dpkg --purge --force-all mysql-server-8.0

dpkg: warning: overriding problem because --force enabled:
dpkg: warning: package is in a very bad inconsistent state; you should
 reinstall it before attempting a removal
(Reading database ... 281877 files and directories currently installed.)
Removing mysql-server-8.0 (8.0.22-0ubuntu0.20.04.3) ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
dpkg: error processing package mysql-server-8.0 (--purge):
 installed mysql-server-8.0 package pre-removal script subprocess returned error exit status 1
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
Failed to start mysql.service: Unit mysql.service not found.
invoke-rc.d: initscript mysql, action "start" failed.
Unit mysql.service could not be found.
dpkg: error while cleaning up:
 installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 mysql-server-8.0

dpkg --install /var/cache/apt/archives/mysql-server-8.0_8.0.23-0ubuntu0.20.04.1_amd64.deb

Selecting previously unselected package mysql-server-8.0.
(Reading database ... 281878 files and directories currently installed.)
Preparing to unpack .../mysql-server-8.0_8.0.23-0ubuntu0.20.04.1_amd64.deb ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
dpkg: warning: old mysql-server-8.0 package pre-removal script subprocess returned error exit status 1
dpkg: trying script from the new package instead ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
dpkg: error processing archive /var/cache/apt/archives/mysql-server-8.0_8.0.23-0ubuntu0.20.04.1_amd64.deb (--install):
 new mysql-server-8.0 package pre-removal script subprocess returned error exit status 1
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
Failed to start mysql.service: Unit mysql.service not found.
invoke-rc.d: initscript mysql, action "start" failed.
Unit mysql.service could not be found.
dpkg: error while cleaning up:
 installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/mysql-server-8.0_8.0.23-0ubuntu0.20.04.1_amd64.deb
apt install --reinstall mysql-server-8.0
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  mailx tinyca
The following packages will be upgraded:
  mysql-server-8.0
1 upgraded, 0 newly installed, 0 to remove and 53 not upgraded.
1 not fully installed or removed.
Need to get 0 B/1,275 kB of archives.
After this operation, 14.3 kB of additional disk space will be used.
Preconfiguring packages ...
(Reading database ... 281878 files and directories currently installed.)
Preparing to unpack .../mysql-server-8.0_8.0.23-0ubuntu0.20.04.1_amd64.deb ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
dpkg: warning: old mysql-server-8.0 package pre-removal script subprocess returned error exit status 1
dpkg: trying script from the new package instead ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
dpkg: error processing archive /var/cache/apt/archives/mysql-server-8.0_8.0.23-0ubuntu0.20.04.1_amd64.deb (--un
pack):
 new mysql-server-8.0 package pre-removal script subprocess returned error exit status 1
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
Failed to start mysql.service: Unit mysql.service not found.
invoke-rc.d: initscript mysql, action "start" failed.
Unit mysql.service could not be found.
dpkg: error while cleaning up:
 installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/mysql-server-8.0_8.0.23-0ubuntu0.20.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Failed command list:

All of the following failed, same error as above:

dpkg --purge --force-all mysql-server-8.0

dpkg --install mysql-server-8.0

dpkg --install /var/cache/apt/archives/mysql-server-8.0_8.0.23-0ubuntu0.20.04.1_amd64.deb

dpkg --remove --force-all mysql-server-8.0

dpkg --configure -a

dpkg --purge --force-all mysql-server-8.0

apt install --reinstall mysql-server-8.0
Leam Hall
  • 11
  • 3
  • Try this `sudo dpkg --remove --force-all mysql-server-8.0` – Emil Feb 25 '21 at 12:33
  • You may need to use the `--configure` flag to resolve this: `sudo dpkg --configure -a`. This will try to install all packages that are in a partial state. –  Feb 25 '21 at 12:49
  • 1
    As it say's `you should reinstall it before attempting a removal`. So something like `sudo apt install --reinstall mysql-server-8.0` may help if the package is the repositories or added ppa's. – Soren A Feb 25 '21 at 12:49
  • All of the following failed, same error as above: dpkg --purge --force-all mysql-server-8.0 dpkg --install mysql-server-8.0 dpkg --install /var/cache/apt/archives/mysql-server-8.0_8.0.23-0ubuntu0.20.04.1_amd64.deb dpkg --remove --force-all mysql-server-8.0 dpkg --configure -a dpkg --purge --force-all mysql-server-8.0 apt install --reinstall mysql-server-8.0 – Leam Hall Feb 25 '21 at 13:41
  • My apologies for the lack of line-feeds to make that readable, not sure how to format here. – Leam Hall Feb 25 '21 at 13:49
  • Add it to your question. Comments are intended to help you improve your question. – user535733 Feb 25 '21 at 14:01
  • Please add the complete output of the --reinstall attempt. – user535733 Feb 25 '21 at 14:04
  • Added output from --reinstall. – Leam Hall Feb 25 '21 at 15:17
  • Does this answer your question? [How to fix "Package is in a very bad inconsistent state" error?](https://askubuntu.com/questions/148715/how-to-fix-package-is-in-a-very-bad-inconsistent-state-error) – karel Jan 12 '22 at 06:44

1 Answers1

0

Try running this first:

sudo systemctl disable mysql
Magmatic
  • 101
  • 2