Home > Database > Mysql Tutorial > How to read mysql binlog

How to read mysql binlog

藏色散人
Release: 2020-10-21 11:30:35
Original
6460 people have browsed it

In MySQL or MariaDB, whenever you make a change to the database, that specific event is logged.

How to read mysql binlog

For example, when you create a new table or update data on an existing table, these events will be stored in mysql binlog, which is the MySQL database The Binary log.

Binary logs are very useful in MySQL replication, 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 and user-friendly format.

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

The following is an introduction to the command method to obtain the current binary log list.

Execute the following show binary logs command 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 |
..
..
Copy after login

If your system does not have binary logging enabled, you will see the following error message.

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

Where is the location of mysql binlog?

By default, the binary log file is 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
..
..
Copy after login

Recommended reference for free learning: "mysql tutorial"

The above is the detailed content of How to read mysql binlog. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template