Check whether event is enabled
The Code is as follows:
Show variables like '% sche % ';
Enable the event plan
The Code is as follows:
Set global event_scheduler = 1;
Create a stored procedure test
The Code is as follows:
Create procedure test ()
BEGIN
Update examinfo SET endtime = now () WHERE id = 14;
END;
Create event e_test
The Code is as follows:
Create event if not exists e_test
On schedule every 30 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 Record id = 14 in examinfo.
Close event task
The Code is as follows:
Alter event e_test ON
Completion preserve disable;
Account Opening event task
The Code is as follows:
Alter event e_test ON
Completion preserve enable;
All tests are successful. The test environment is mysql 5.4.2-beta-community mysql community server (GPL)
The above content is an introduction to the regular execution of MySQL. I hope you will have some gains.
The scheduled mysql task disappears after being restarted.
You only need to modify the configuration.
Event_scheduler is set to OFF in mysql config. Change the configuration to ON in mysql.