'Cannot uninstall mysql-server-8.0
after installing mariadb with mysql already installed, i had issues and mysql wasent working so i tried to uninstall mysql and the package broke. after frustrating hours of trying to fix this i stupidly deleted all the mysql files. at the moment:
ive tried dpkg -l | grep mysql
, and get nothing
so i tried dpkg -l | grep mysql
and got,
mysql-client-8.0 install
mysql-client-core-8.0 install
mysql-common install
mysql-server-8.0 install
mysql-server-core-8.0 install
php7.4-mysql install
after trying to remove mysql-server-8.0:
sudo dpkg --remove --force-remove-reinstreq mysql-server-8.0
i get:
(Reading database ... 219264 files and directories currently installed.)
Removing mysql-server-8.0 (8.0.22-0ubuntu0.20.10.2) ...
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 (--remove):
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
Is there a way to fix this and completely wipe mysql and then install mariadb?? If not i suppose the only way to fix this is to reinstall the os . thanks!!
Solution 1:[1]
After doing some looking, I found another post on ServerFault that details issues with the install script. I was having this same issue, and after ensuring that all MySQL files were removed I went to /var/lib/dpkg/info
and ran sudo rm -rf ./mysql-*
. After doing that you should be OK to run sudo dpkg --remove --force-remove-reinstreq mysql-server-8.0
followed by a sudo dpkg --purge mysql-server-8.0
.
This is a nuclear option and I would not recommend doing this until you are 100% sure that there are no more files from the MySQL install.
Solution 2:[2]
cd /var/lib/dpkg/info
sudo rm -rf ./mysql-*
sudo dpkg --remove --force-remove-reinstreq mysql-server-8.0
It is ok!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | TRKZI Omar |
Solution 2 | dragon fly |