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
sudo dpkg --remove --force-all mysql-server-8.0
– Emil Feb 25 '21 at 12:33--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:49you should reinstall it before attempting a removal
. So something likesudo 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:49dpkg --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