Get the App
SLTechnology News&Howtos  ›  Database  › 

How to convert bin-log log files to sql files in mysql

Shulou Source: shulou.com Published: 2022-05-31 22:17:59 10月01日 Update

This article is about how to convert bin-log log files into sql files in mysql, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

View mysqlbinlog version

Mysqlbinlog-V [--version]

Check the binlog log open status

Show variables like'% log_bin%'

When mysql opens the bin-log log, the non-query operation of the mysql database saves the record to the bin-log file. General bin-log log files can not be opened to view, need to use mysql tools. Suppose the binary file mysql-bin.000011 is stored in the / mysql/data/ directory. You need to export the sql statement about the database tide in the log file mysql-bin.000011 to the file tide.sql, as follows:

/ / transfer the sql of the binlog log file about the tide library to the file mysqlbinlog mysql-bin.000011-d tide > tide.sql / / Select a time range to export mysqlbinlog-- start-date= "2017-08-12 15:00:19"-- stop-date= "2017-08-12 15:30:19" mysql-bin.000011-d tide > tide.sql

If the binlog log file is recorded in ROW format

/ / transfer the binlog log file in row format to the file after base64 parsing, and-v represents line break to show mysqlbinlog-- base64-output=decode-rows-v mysql-bin.000011-d tide > tide.sql

After execution, a tide.sql file will be generated in the current directory. You can use vim/vi to open the file.

The above is how to convert bin-log log files into sql files in mysql. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Tags: File log lieutenant general data database more format directory knowledge article practical binary representative that is work meeting tool article time version status Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker MariaDB Microsoft Apple Xiaomi