Error
Error Code:
1544
MySQL Error 1544: Event Scheduled in Past
Description
This error occurs when a MySQL Event Scheduler event is defined or modified with a `STARTS` or `AT` timestamp that is in the past relative to the current server time. MySQL disables such events to prevent immediate, unintended execution or to indicate an invalid schedule.
Error Message
Event execution time is in the past. Event has been disabled
Known Causes
3 known causesIncorrect Event Definition Time
The `STARTS` or `AT` timestamp for the event was explicitly set to a date and time that has already passed.
Server Time Drift
The MySQL server's system clock is significantly behind the actual current time, causing a valid future event time to appear to be in the past.
Time Zone Mismatch
A discrepancy between the time zone settings of the client creating the event and the MySQL server, leading to an incorrect interpretation of the scheduled time.
Solutions
3 solutions available1. Reschedule Event to Current or Future Time easy
Adjust the event's execution time to a valid point in the future.
1
Identify the event that caused the error. You can find this in the MySQL error log or by querying the `mysql.event` table.
SELECT * FROM mysql.event WHERE status = 'DISABLED';
2
Determine the correct future execution time for the event. This depends on the event's purpose.
SELECT NOW();
3
Modify the event's schedule using the `ALTER EVENT` statement. Replace `your_event_name` with the actual name of the event and `YYYY-MM-DD HH:MM:SS` with the desired future execution time.
ALTER EVENT your_event_name ON SCHEDULE AT 'YYYY-MM-DD HH:MM:SS';
-- Example: To run an event immediately if it was scheduled in the past
-- ALTER EVENT your_event_name ON SCHEDULE AT CURRENT_TIMESTAMP;
-- Example: To reschedule an event for tomorrow at 9 AM
-- ALTER EVENT your_event_name ON SCHEDULE AT DATE_ADD(CURDATE(), INTERVAL 1 DAY) + INTERVAL 9 HOUR;
4
Enable the event if it was automatically disabled due to the past execution time.
ALTER EVENT your_event_name ENABLE;
2. Recreate Event with Correct Schedule medium
Drop and recreate the event with a valid schedule if direct modification is complex.
1
Identify the event name and its definition. You can retrieve the event definition using `SHOW CREATE EVENT`.
SHOW CREATE EVENT your_event_name;
2
Drop the existing event.
DROP EVENT your_event_name;
3
Recreate the event using the definition obtained in step 1, but with a corrected `ON SCHEDULE` clause pointing to a future time. Ensure the schedule is valid.
CREATE EVENT your_event_name
ON SCHEDULE AT 'YYYY-MM-DD HH:MM:SS' -- Replace with your desired future time
DO
-- your event body here
;
3. Adjust MySQL Server Time advanced
If the server's system time is incorrect, correct it to resolve past scheduling issues.
1
Check the current system time on the MySQL server. This might require server access.
date
2
If the system time is incorrect, adjust it using the appropriate system commands (e.g., `date` or `timedatectl` on Linux). This often requires root privileges.
# Example for Linux (requires root):
sudo timedatectl set-time 'YYYY-MM-DD HH:MM:SS'
# Or for older systems:
sudo date -s 'YYYY-MM-DD HH:MM:SS'
3
After correcting the system time, you may need to restart the MySQL server for the changes to be fully recognized by the event scheduler.
# Example for systemd-based systems (requires root):
sudo systemctl restart mysql
# Or for older init systems:
sudo service mysql restart
4
Once the server time is corrected and the server is restarted, you may need to re-enable the disabled events.
ALTER EVENT your_event_name ENABLE;