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.

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.

×
1 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:
  • 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:
  • sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql
  • Finally clean all packages that are not needed:
  • sudo apt autoremove
  • 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

  • Finally it works, thanks a lot. Now I have to do that about binary logs, but what happened that my disk got full in just ten days?

    One more time thanks for your help.

    • Hey @themingisprose,

      No problem at all! Happy to hear that it is all working now.

      Regarding the binary logs, those should only appear if you have MySQL replication configured, is this the case for you?

      If you are using MySQL 5.x, and if you are using MySQL replication, then I would recommend reducing the expire_logs_days value in MySQL.

      If you are using Percona, you could adjust the max_binlog_files number instead.

      Hope that this helps!
      Regards,
      Bobby

      • Hi @bobbyiliev

        About my MySQL configuration, I’ve been following thees steeps, not mush else. I’m a bit new to all of this.

        So, following your tutorial, I found that expire_logs_days is deprecated, but the error message guided me through out the right way.

        mysql> SET GLOBAL expire_logs_days = 3;
        ERROR 3683 (HY000): The option expire_logs_days and binlog_expire_logs_seconds cannot be used together. Please use binlog_expire_logs_seconds to set the expire time (expire_logs_days is deprecated)
        mysql> SET GLOBAL binlog_expire_logs_seconds = 259000;
        Query OK, 0 rows affected (0.00 sec)
        
        

        Then added this to my /etc/mysql/my.cnf file. (I don’t have the /etc/my.cnf file):

        [mysqlg]
        binlog_expire_logs_seconds = 259000
        

        Now on I’ll keep an eye on these files, hopefully they will not cause troubles anymore :)

        Thanks

        by Erika Heidi
        A “LAMP” stack is a group of open-source software that is typically installed together to enable a server to host dynamic websites and web apps. This term is actually an acronym which represents the Linux operating system, with the Apache web server. The site data is stored in a MySQL database, and dynamic content is processed by PHP. In this guide, we will install a LAMP stack on an Ubuntu 20.04 server.
Submit an Answer