For a MySQL database with a large number of accesses, the increment of the binary log is usually very fast, which is likely to surprise you. Like a racetrack, most of your disks will be filled with logs.
Problems always need to be solved, and there are always ways to solve them:
Method one, use Php,perl,python,java and so on realization
After connecting to the database, execute according to your needs: Purge binary logs before .... or purge binary logs to ... Command. (Please refer to the MySQL manual for detailed instructions on these two commands.)
Then, add the command that executes the script to the crontab scheduled task
Method two, using the shell
Create the following shell script:
#!/bin/bash
Mysql-u username-h Host-ppassword Mysql<<eofmysql
Pugre binary logs before Current_timestamp-interval 7 day #或purge binary logs to mysql-bin.00043
Eofmysql
Modify the relevant permissions for the script (executable, etc.)
Then, add the command that executes the script to the crontab scheduled task
Use MySQL purge to manually clear the binary log