Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
503 views
in Technique[技术] by (71.8m points)

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!!

question from:https://stackoverflow.com/questions/65949014/cannot-uninstall-mysql-server-8-0

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

This is a nuclear option and I would not reccomend doing this until you are 100% sure that there are no more files from the MySQL install.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...