Reputation: 5941
I am creating an event (like crone job) in MySQL to execute a query every 3 seconds but does not work. I tried my best. Here is my code please see if I am doing anything wrong
CREATE EVENT `croneJob`
ON SCHEDULE EVERY 3 SECOND
STARTS '2014-03-24 13:45:57'
ON COMPLETION PRESERVE ENABLE
DO
insert into ranktable values (1,2,3);
It successfully creates it but does not execute every 3 seconds
Upvotes: 1
Views: 410
Reputation: 5941
Even setting
SET GLOBAL event_scheduler = ON;
was not working so I put these lines in my.ini
[mysqld]
event_scheduler = ON
and is working great now.
Upvotes: 0
Reputation: 6525
As I know all events are executed by a special event scheduler thread.When we refer to the Event Scheduler, we actually refer to this thread.There is global event_scheduler
system variable determines whether the Event Scheduler is enabled and running on the server.
Try to set the event_Scheduler on your command line.
SET GLOBAL event_scheduler = ON;
OR
SET GLOBAL event_scheduler = 1;
Read more about events.
Hope it will help you.
Upvotes: 2
Reputation: 27702
You have to start your MySQL server events scheduler:
SET GLOBAL event_scheduler = ON;
Loot at:
https://dev.mysql.com/doc/refman/5.1/en/events-configuration.html
Upvotes: 2