mysql -u root -p -e "PURGE BINARY LOGS BEFORE NOW() - INTERVAL 7 DAY;"
Delete binary logs older than a week
Removes binlog files older than seven days, freeing disk on servers that keep binary logging for replication or point-in-time recovery. Only the oldest files are purged; active ones stay. Verify the replica has consumed the logs first, or replication breaks.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.