DEV Community

Cover image for Clear out MySql/MariaDB binary log files
Kinjal
Kinjal

Posted on

4 1

Clear out MySql/MariaDB binary log files

I came across the following error while resroting a databsae in MariaDB.



ERROR 3 (HY000) at line 87066: Error writing file '/tmp/MLvCaXNh' (Errcode: 28 "No space left on device") 


Enter fullscreen mode Exit fullscreen mode

This is due to the excesive binary logs which are generated by database server.

From MariaDB documentation - The binary log contains a record of all changes to the databases, both data and structure, as well as how long each statement took to execute. It consists of a set of binary log files and an index.

It is required to periodically clear out those logs to avoid runninng into the problem of No space left on device.

Clearing old log files also helps the process of database replication.

List all the binary logs:



mysql> show binary logs;


Enter fullscreen mode Exit fullscreen mode

And the query to delete all old files that were generated 2 days back:



mysql> purge binary logs before date(now() - interval 2 day);


Enter fullscreen mode Exit fullscreen mode

You can only delete the files that are older than the oldest file that is used by the slaves.

The diskspace error should be gone after clearing the logs.

Where these log files are stored?
mysql-binary-log

Usually log files are stored in /opt/mariadb/data.
Alt Text

Reference:
PURGE BINARY LOGS

Image of Stellar post

How a Hackathon Win Led to My Startup Getting Funded

In this episode, you'll see:

  • The hackathon wins that sparked the journey.
  • The moment José and Joseph decided to go all-in.
  • Building a working prototype on Stellar.
  • Using the PassKeys feature of Soroban.
  • Getting funded via the Stellar Community Fund.

Watch the video 🎥

Top comments (0)

Image of PulumiUP 2025

Let's talk about the current state of cloud and IaC, platform engineering, and security.

Dive into the stories and experiences of innovators and experts, from Startup Founders to Industry Leaders at PulumiUP 2025.

Register Now

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, cherished by the supportive DEV Community. Coders of every background are encouraged to bring their perspectives and bolster our collective wisdom.

A sincere “thank you” often brightens someone’s day—share yours in the comments below!

On DEV, the act of sharing knowledge eases our journey and forges stronger community ties. Found value in this? A quick thank-you to the author can make a world of difference.

Okay