Search code examples
mysqlmysql-eventmysql-routines

Mysql Event Not Working


I have added the following simple test event on my mysql database via phpmyadmin:

CREATE DEFINER=`root`@`localhost` EVENT `my_event` 
ON SCHEDULE EVERY 1 MINUTE STARTS '2013-05-27 00:00:00' 
ON COMPLETION NOT PRESERVE ENABLE DO 
BEGIN
    UPDATE `test` SET `name`="z";
END

My environment is mac + MAMP Pro. I am expecting to change all rows on my 'test' table with name 'z' within a minute. But not happening so.

Do I have to something additional to get my events start working?

Output of "SHOW PROCESSLIST": enter image description here

Thanks.


Solution

  • Events are run by the scheduler, which is not started by default. Using SHOW PROCESSLIST is possible to check whether it is started. If not, run the command

     SET GLOBAL event_scheduler = ON;
    

    to run it.