Home > Database > Mysql Tutorial > How to delete mysql binary log

How to delete mysql binary log

WBOY
Release: 2022-05-19 16:41:50
Original
3111 people have browsed it

Method: 1. Use the "RESET MASTER" and "RESET SLAVE" commands to delete binary logs; 2. Use the "PURGE BINARY LOGS" statement to delete binary logs; 3. Use the "mysqladmin flush-logs" command to delete more than Three days of binary logs.

How to delete mysql binary log

The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.

How to delete the mysql binary log

1. Use the RESET MASTER statement to delete the MySQL binary log

The Reset Master statement is used to replicate the Master and Slave servers. Start a new database during this period. This statement can be used to delete all binary logs.

Clean the binary logs on the Master server:

shell> mysql -u username -p
mysql> RESET MASTER;
Copy after login

Clean the binary logs on the Slave server:

mysql -u username -p
mysql> RESET SLAVE;
Copy after login

2. Use the PURGE BINARY LOGS statement to delete the MySQL binary logs

The PURGE BINARY LOGS statement can delete Binary Log based on date or up to Binary Log sequence number.

Based on the binary log example shown above, I would like to delete binaries up to mysql-bin.000015 (retained):

shell> mysql -u username -p
mysql>PURGE BINARY LOGS TO 'mysql-bin.000015';
Copy after login

Alternatively, you can delete binaries older than a specific date:

shell> mysql -u username -p
mysql> PURGE BINARY LOGS BEFORE '2009-05-01 00:00:00';
Copy after login

3. Use the mysqladmin flush-logs command to delete MySQL Binary Log

Another method is to run the mysqladmin flush-logs command, which will delete the logs older than 3 days. Binary log.

shell> mysqladmin -u username -p flush-logs
Copy after login

Recommended learning: mysql video tutorial

The above is the detailed content of How to delete mysql binary log. 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