Use the mysql event scheduler to regularly delete binlog_MySQL

Source: Internet
Author: User
Use the mysql event scheduler to regularly delete binlog bitsCN. the event scheduler of comMySQL can execute a task accurately every second. it is suitable for applications with high real-time data requirements (such as stocks, odds, and scores.
First, check whether this function is enabled:
SELECT @ event_scheduler;
Before using this function, make sure that event_scheduler is enabled. you can execute:
Set global event_scheduler = 1;
Or we can add event_scheduler = 1 to the my. cnf file.
Then, write an event to delete the binlog. set the daily check and delete the binlog file four days ago.
Create event purge_binlog on schedule every 1 day do purge master logs before DATE_SUB (NOW (), INTERVAL 4 DAY );
To view scheduled events, run the following statement:
SELECT * FROM information_schema.EVENTS;
You can see the job information in the corresponding database. the LAST_EXECUTED field reflects the last execution time of the corresponding job. BitsCN.com

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.