Use MySQL purge to manually clear the binary log

Source: Internet
Author: User
Tags mysql manual

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.