Mysql binary logs

How to clean old binary logs

Here’s a little quick tip on cleaning your MythTV box of space cluttering binary logs. These are generated for every transaction that Mysql does. So if you have any corruption you can redo the tables. However, if you have a lot of listings data being imported into the table, then these can be pretty large.

mysql -u root --password mythconverg
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 53 to server version: 4.1.21-log

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> show master logs;
+——————-+———–+
| Log_name | File_size |
+——————-+———–+
| mythtv-bin.000001 | 79 |
| mythtv-bin.000002 | 79 |
| mythtv-bin.000003 | 79 |
| mythtv-bin.000004 | 50504 |
| mythtv-bin.000005 | 2767417 |
| mythtv-bin.000006 | 42523 |
| mythtv-bin.000007 | 79 |
| mythtv-bin.000008 | 7099399 |
| mythtv-bin.000009 | 60102 |
| mythtv-bin.000010 | 23028247 |
| mythtv-bin.000011 | 13157557 |
| mythtv-bin.000012 | 3300816 |

mysql> purge master logs to ‘mythtv-bin.010’;

This entry was posted in Computergeekery and tagged . Bookmark the permalink.

One Response to Mysql binary logs

  1. Jon Wood says:

    I just found this while trying to work out how to stop a MySQL server eating all it’s disk space with binary logs.

    If you’re not using the binary logs, then you can turn them off entirely by commenting out the line

    log_bin = /path/to/mysql-bin.log

    In your MySQL configuration file.

Comments are closed.