DEV Community

Aashutosh Poudel
Aashutosh Poudel

Posted on

2

Cleanup large binary logs in MySQL

I had an issue where my drive was almost occupied by mysql log files (almost 400G). I am not sure about the cause of the issue but I needed a way to remove those files fast. This was in my local dev machine so I decided to remove those files completely.

Here's a few commands to help you purge those files.

To purge logs created until a specific date:
mysql> PURGE BINARY LOGS BEFORE '2022-11-25 00:00:00';

To expire logs after certain time:
mysql> SET GLOBAL binlog_expire_logs_seconds=86400;

Additionally, set binlog_expire_logs_seconds in a config file to persist it between service restarts.

References:

  1. How to Solve Increasing Size of MySQL Binlog Files Problem?
  2. binlog_expire_logs_seconds docs

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay