Mysql Event Not Working

前端 未结 9 1794
-上瘾入骨i
-上瘾入骨i 2021-01-30 10:46

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          


        
9条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-30 11:07

    For those wondering how to enable it by default at startup, add the following to your config file (my.ini, my.cnf):

    #Event scheduler can be set to 1 (On), 0 (Off), or Disabled
    event_scheduler=1
    

    Restart of the service is required in this case, so if you want minimal disruption, add this to the config file, and then run the SQL:

    SET GLOBAL event_scheduler = ON;
    

    That way, it will run for the current process, and if the server is restarted it will still work.

    Note that this doesn't work if the event_scheduler was set to disabled. In that case the only option is to restart the service.

提交回复
热议问题