Manually flush the binary logs in MySQL

Change the binary logs file manually in MySQL

Close the current binary log file and begin a new one manually by issuing a FlUSH LOGS Command.

Suppose we want to take backup of database, we can do it manually before start to change the binary log or we want to do any testing and restore database at point of time we can flush to change the binary logs.

Example of Flush Logs command

mysql> SHOW BINARY LOGS;
+-----------------+-----------+-----------+
| Log_name        | File_size | Encrypted |
+-----------------+-----------+-----------+
| RAC1-bin.000001 |       202 | No        |
| RAC1-bin.000002 |       156 | No        |
+-----------------+-----------+-----------+
2 rows in set (0.00 sec)

mysql> flush logs;
Query OK, 0 rows affected (0.06 sec)

mysql> SHOW BINARY LOGS;
+-----------------+-----------+-----------+
| Log_name        | File_size | Encrypted |
+-----------------+-----------+-----------+
| RAC1-bin.000001 |       202 | No        |
| RAC1-bin.000002 |       202 | No        |
| RAC1-bin.000003 |       156 | No        |
+-----------------+-----------+-----------+
3 rows in set (0.01 sec)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.