1. After connecting and logging in to MySQL, first check whether the event function is enabled in MySQL: Command: show variables like '%sc%'; It is found that event_sheduler is OFF; 2. Open event_scheuler: Temporarily enabled (invalid after restarting MySQL service) SET GLOBAL event_scheduler = ON; SET GLOBAL event_scheduler = 1; — 0 means off Permanently open Add the following content to the [mysqld] section in my.cnf, and then restart mysql (mysql restart command: service mysqld restart) event_scheduler=ON 3. Create an event. Here is an example to delete data in the wififlows table that is 2 minutes old and expired every 5 seconds: create event e_delete_wififlows on schedule every 5 seconds do delete from wififlows where timestamp < (CURRENT_TIMESTAMP() + INTERVAL -2 MINUTE); If this event already exists, you can delete it using the following command: drop event if exists e_delete_wififlows; Then use show events; to view the existing events 4. Open the event: alter event e_del_wififlows on completion preserve enable; 5. Close event: alter event e_del_wififlowa on completion preserve disable; The above simple method of regularly deleting expired data records in MySQL is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Basic usage and examples of yum (recommended)
1. What is Refs is called Resilient File System (...
Mysql8.0.12 decompression version installation me...
The format of textarea can be saved to the databas...
The information on Baidu is so diverse that it...
I recently encountered a problem at work. There i...
Preface Review and summary of mobile terminal rem...
Table of contents Manual backup Timer backup Manu...
Result:Implementation code: <!DOCTYPE html>...
Table of contents 1. Basic types 2. Object Type 2...
I. Introduction First, let me explain the version...
This article will introduce how to use explain to...
Eating well and getting enough rest sounds simple...
I reinstalled VMware and Ubuntu, but the command ...
Implement div wheel zooming in and out in Vue pro...
After installing the latest version 8.0.11 of mys...