We delete binary mysql logins on our server
Freeing up space on a virtual server
Creation, development, manufacturing sites | WEB-STYDIA.COM

Greetings to the distinguished visitor of our site. This article, or rather, most likely just a note for users of their own servers.

Not long ago I noticed that one of my VPS servers was completely jammed and the disk space on it was over. There was just a couple of created web sites on WordPress and on opencart which already could not be so big as to fill 50GB of memory. I had to figure out what the problem was.

It turned out all very trite. After examining the size of all the folders on the server, I noticed that one of the folders is much more than the folder /var/lib/mysql, it had a lot of files like mysql-bin.000010, mysql-bin.000001, mysql-bin .000002, mysql-bin.000003, mysql-bin.000004, mysql-bin.000005, and so on. There were a lot of such files and they all did not have a small size, some files reached 1GB.

What are these files and what are they for? - These are binary logs of database operations in mysql, and their main purpose is this:

  • It is used for database replication, in case we have many databases that are configured for replication.
  • It is used to restore databases in the event of a breakdown or failure.

In fact, you can safely remove all these binary files, nothing terrible will happen, you clear the place and everything will be fine, but: First, after a while the story will repeat and you again have to do everything again, and in the second we are of course concerned with the second paragraph this is a recovery in case of a database failure. Therefore, I do not recommend completely deleting all binary files, but it's better to delete only those that you do not really need anymore, being guided by the date of file creation.

And so manually deleting binary files:

In this example, as you probably already guessed, we delete a specific file with a binary log or delete the log with the specified date.

But I did everything differently, I did not bother and manually delete all the binary logs, and I instructed the server to do it myself, for this purpose I just need to add one line to the my.conf configuration file:

By this line, we tell the server that we need to store binary logs for no more than five days. After rebooting mysqld server and all binary log files will be deleted automatically except for files of the last five days.

That's all, now your server will not be filled with unnecessary logs. Good luck to you.

You may also like

No Comment

You can post first response comment.

Leave A Comment

Please enter your name. Please enter an valid email address. Please enter a message.