Question

Completley reset mysql installation including files that come with the OS

I am in Ubuntu 20.04. I followed the MySQL installation tutorial and I got an error after running sudo mysql_secure_installation so I decided to uninstall and reinstall. I tried the entire process again and I started getting a different error. I then began trying various methods of wiping the system clean of MySQL (and I clearly broke something) so I had to revert to a backup of the server. I’ve run into so many different errors that I can’t really keep track of what the problem actually is and I would just like to completely start over in regards to MySQL. I’ve tried purge and everything like that but it hasn’t reset everything. I assume some files come preinstalled with Ubuntu and those don’t get touched when running most remove commands.


Submit an answer
Answer a question...

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.

KFSys
Site Moderator
Site Moderator badge
June 11, 2022

Hi @leoddc,

There are no files related to MySQL that come with the OS, however purging or removing MySQL with apt does not remove all files created before the installation process. Here is what you can do

  1. sudo apt purge mysql-server*
  1. ls /etc/mysql
  2. sudo ls /var/lib/mysql

If those folders are still on your Droplet remove them like:

  1. sudo rm -r /etc/mysql /var/lib/mysql
  2. sudo rm -r /var/log/mysql

Then do an autoremove:

  1. sudo apt autoremove

That should be enough.