See if the event is open
| The code is as follows |
Copy Code |
Show variables like '%sche% ';
|
To open an event plan
| The code is as follows |
Copy Code |
Set global Event_scheduler = 1;
|
Create stored Procedure test
| The code is as follows |
Copy Code |
CREATE PROCEDURE Test () BEGIN Update Examinfo SET endtime = Now () WHERE id = 14; End;
|
Create Event E_test
| The code is as follows |
Copy Code |
Create event if not exists e_test On schedule every second On completion Preserve Do call Test ();
|
The stored procedure test is executed every 30 seconds, and the current time is updated to the Endtime field of the id=14 record in the Examinfo table.
Shutdown Event Task
| The code is as follows |
Copy Code |
Alter event e_test on Completion PRESERVE DISABLE;
|
Account Opening Event Task
| The code is as follows |
Copy Code |
Alter event e_test on Completion PRESERVE ENABLE;
|
All of the above tests were successful and the test environment was MySQL 5.4.2-beta-community MySQL Community server (GPL)
The above related content is the introduction of the MySQL timing, hope you can have some harvest.
MySQL scheduled task restarts and disappears
We just need to modify a configuration to
Event_scheduler is set to off in MySQL config. Go to MySQL and change the configuration to on and it's done.