Search code examples
mysql

How to force an event to execute in MySQL


I am trying to write an automated test script for testing a MySQL Event that I created, and I am wondering if there is a way to execute some kind of command to force the Event to execute immediately. The Event is set to run daily at midnight, but I don't want the automated test script to have to wait for the Event to trigger.

One way I can think of is to ALTER the Event to have it execute one-time 5 seconds into the future, but I'd like to know if there is a more elegant way to do get it to execute.


Solution

    1. Move all the code within the event into a stored procedure
    2. Make the event only call the stored procedure
    3. Test the stored procedure with the CALL syntax.