Trying to purge mysql fails

I really messed up my mysql installation trying to rapidly setup Owncloud on a new install of Ubuntu 20.04 LTS server. Sadly I already setup many services that are running well, so I just want to completely purge mysql and setup again from scratch. I have tried following various tutorials about

sudo apt-get purge mysql*

However, all variations end with this very similar error and I cannot continue and trying to ignore and re-install mysql just fails. How can I force remove all mysql of this box and start that again?

Thanks for any help.

Error: (Reading database … 160886 files and directories currently installed.) Removing mysql-server-8.0 (8.0.23-0ubuntu0.20.04.1) … 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 dpkg: too many errors, stopping 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 Processing was halted because there were too many errors. E: Sub-process /usr/bin/dpkg returned an error code (1)

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi there,

In addition to what KFSys already mentioned, I could suggest also taking a look at this answer here:

Regards, Bobby

Hi @jonathankonrad,

I’ve had the same issue before. What it worked for me in that case was :

sudo apt-get remove --purge mysql* 
sudo apt-get purge mysql*
sudo apt-get autoremove 
sudo apt-get autoclean
sudo apt-get remove dbconfig-mysqlthen

Please give it a try one more time and see if it would work that way.

Looking forward to your reply!

Regards, KFSys