Question

Completely uninstall mysql-server

Hi there, first of all I need to make some history to tell why am getting to this point.

A few days ago, making a multisite WordPress installation I lost access to database. This I solved it without breaking my head.

Yesterday I got notified that my WordPress was down, but what a surprise, my disk was full (25G). So I follow thees steps to solve that, then I saw that the problem was in /var/lib/mysql with a lot of files binlog.000000 ~100M size. So I delete them all with rm, I don’t know if that was the right way.

Then all the problems start. I try to enter to mysql console, but it is imposible, always get this massage: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

I’ve followed this tutorial and many others like this one, but nothing.

The directory /var/run/mysqld/ has owner and permissions drwxr-xr-x 2 mysql mysql 40 Jun 21 09:19. I’ve restarted mysql.service many times, but the mysqld.sock file is not created.

Last thing I did was uninstall mysql-service:

sudo apt remove --purge mysql-server
sudo apt purge mysql-server
sudo apt autoremove
sudo apt autoclean
sudo apt remove dbconfig-mysql

I’ve installed again, but when I try to access to mysql console get the same error again.

My droplet is SO Ubuntu 20.04 and MySQL version 8.0.20. I don’t know if there could be some issues in this latest versions of Ubuntu and MySQL.

I don’t care a lot to lose all my data, be cause it is a new droplet and I have almost nothing there, but I like to fix this problem in the right way.

Thank a lot for your help.


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.

Accepted Answer

Hi there @themingisprose,

Indeed deleting files directly from your MySQL folder is really not recommended. You can take a look at this guide here on how to delete old MySQL binary files here.

Regarding your current issue. In order to completely get rid of your MySQL installation you could run the following:

  • Make sure MySQL is not running:
  1. sudo systemctl stop mysql
  • Then purge all of the MySQL packages:
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*
  • Then delete all of the MySQL files:
  1. sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql
  • Finally clean all packages that are not needed:
  1. sudo apt autoremove
  2. sudo apt autoclean

Another approach here would be to create a new Droplet and just upload your WordPress files to the new Droplet.

Hope that this helps! Regards, Bobby

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.