I have Win XP os and XAMPP installed in my machine.
I need to execute my event/scheduler at 12:00:00 AM of First day of every month. Means 1st of every month. (e.g. jan 1st, Feb1 1st, March 1st, ... ).
And I also need to call the stored procedure in the same event. And I want achieve all this using Event/Job only not from front end.
Please spend few minutes for my query.
Creating new MySQL events First, specify the name of the event that you want to create the CREATE EVENT keywords. The event names must be unique within the same database. Second, specify a schedule after the ON SCHEDULE keywords. Third, place SQL statements after the DO keyword.
run this command : SET GLOBAL event_scheduler = ON; If ERROR 1229 (HY000): Variable 'event_scheduler' is a GLOBAL variable and should be set with SET GLOBAL: mportant.
The MySQL Event Scheduler manages the scheduling and execution of events, that is, tasks that run according to a schedule.
SELECT * FROM INFORMATION_SCHEMA. events; You can also use SHOW CREATE EVENT yourevent to see what it does.
The MySQL event syntax is very simple -
DELIMITER $$
CREATE EVENT event1
ON SCHEDULE EVERY '1' MONTH
STARTS '2011-05-01 00:00:00'
DO
BEGIN
-- your code
END$$
DELIMITER ;
Event will start working on '2011-05-01' at '00:00:00' (datetime must be in a future).
More information - Using the Event Scheduler
Do not forget to enable global event scheduling thread -
SET GLOBAL event_scheduler = 1;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With