Mysql event scheduler regularly deletes binlog_MySQL

Source: Internet
Author: User
Mysql event scheduler regularly deletes binlog bitsCN. the Event sched (Event sched) has been added to Mysql since comMySQL5.1.6. it can be used to regularly execute certain tasks, to replace the previously scheduled tasks that can only be executed by the Linux operating system. the MySQL event scheduler can execute one task exactly every second, it is suitable for applications that require high real-time data (such as stocks, odds, and scores.
First, check whether this function is enabled:
The code is as follows: SELECT @ event_scheduler;
Before using this function, make sure that event_scheduler is enabled. you can execute:
The code is as follows: 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.
The code is as follows: 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:
The code is as follows: 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.