mysql binlog of Binary Log Viewing Method

  • 2021-11-13 03:02:33
  • OfStack

For example, when a new table is created or data on an existing table is updated, these events are stored in the mysql binlog, which is the binary log of the MySQL database.

Binary logs are useful in MySQL replication, where the master server sends data from the binary log to the remote server.

When you perform any type of recovery operation in MySQL, you will also process binary log files.

The mysqlbinlog command is used to view the contents of binary logs in a readable, user-friendly format.

So how do we get to view mysql binlog (binary log)?

The following is a command method to get the current binary log list.

Execute the following command show binary logs from mysql, which will display all binary logs in the system.


mysql> SHOW BINARY LOGS;
+-------------------+-----------+
| Log_name     | File_size |
+-------------------+-----------+
| mysqld-bin.000001 |   15740 |
| mysqld-bin.000002 |   3319 |
..
..

If the system does not enable binary logging, you will see the following error message.


mysql> SHOW BINARY LOGS;
ERROR 1381 (HY000): You are not using binary logging

Where is the location of mysql binlog?

By default, binary log files are located in the/var/lib/mysql directory, as shown below.


# ls -l /var/lib/mysql/
-rw-rw----. 1 mysql mysql 15740 Aug 16 14:57 mysqld-bin.000001
-rw-rw----. 1 mysql mysql 3319 Aug 16 14:57 mysqld-bin.000002
..
..


Related articles: