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":
Thanks.
Remember to add in 'Commit', after 'DO BEGIN' or 'DO'. Works for me after that.
If you want your
event_scheduler
to startup automatically every time mysql server restarts, anywhere under the[mysqld]
section of themy.ini
ormy.cnf
file that you find in/etc/mysql
you should placerestart mysql to check if it is running (in command line terminal!)
then check your processlist
you can check if your events are running by checking the last time they ran
I would just like to add to this thread. I dumped my database to another server and as a result the definer of my event had no such grant defined for the user. I updated my definer with
Make sure your definer has the correct PRIVILEGES.
For those wondering how to enable it by default at startup, add the following to your config file (my.ini, my.cnf):
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:
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.
I just figured out that on MariaDB, after adding an event (in my case, it was the first one), you have to restart the event-scheduler
and then
to make it actually bring the scheduler into "waiting for activation"-state.
Temporal
Will not work if event_scheduler is explicitly DISABLED, see the method below
Permanent (needs restart)
In your config file (In Ubuntu it's
/etc/mysql/mysql.cnf
):Notes:
The
event_scheduler
variable can have this possible states:WARNING: Keywords ON / OFF are preferred over their numerical equivalents. And in fact Mysql Workbench doesn't recognize the configuration
event_scheduler=1
, it shows as OFF in the Options File section. Tested in Ubuntu with Mysql Workbench 8.0.17 and Mysql Server 5.7.27Source: https://dev.mysql.com/doc/refman/5.7/en/events-configuration.html