Why Your Events Stop After Reboot
I've seen this exact problem hundreds of times. You schedule a MySQL event, it runs fine until you restart the server. Then — nothing. Events sit there, ignored.
The culprit is almost always the event_scheduler variable. By default, it's off after a restart on many MySQL installations. You flip it on manually, events work again — but after the next reboot, you're back to square one.
Don't bother checking the event definition first. That's rarely the issue. Start with the simplest fix below.
Step 1: 30-Second Fix — Check Event Scheduler Status
Run this command in MySQL as root or a user with SUPER privileges:
SHOW VARIABLES LIKE 'event_scheduler';
If it shows OFF or DISABLED, that's your problem. Turn it on for the current session:
SET GLOBAL event_scheduler = ON;
Your events should start running immediately. But this is temporary — it won't survive a restart. That's fine for now. You've confirmed the fix.
If event_scheduler already shows ON, move to Step 2.
Step 2: 5-Minute Fix — Make It Permanent
The real fix is to set event_scheduler=ON in the MySQL config file my.cnf (or my.ini on Windows). Here's where to find it:
- Linux: Usually
/etc/my.cnf,/etc/mysql/my.cnf, or/etc/mysql/mysql.conf.d/mysqld.cnf - Windows:
C:\ProgramData\MySQL\MySQL Server 8.0\my.ini(or in the MySQL installation folder) - macOS (Homebrew):
/usr/local/etc/my.cnf
Open the file with sudo or admin rights. Look for the [mysqld] section. If it's missing, add it at the top. Then add this line:
[mysqld]
event_scheduler=ON
Save the file. Restart MySQL:
sudo systemctl restart mysql # Linux (systemd)
sudo service mysql restart # Linux (sysvinit)
After restart, run SHOW VARIABLES LIKE 'event_scheduler'; again. It should show ON. Your events will now run automatically after every reboot.
Step 3: 15+ Minute Fix — When Config Doesn't Stick
Sometimes you add the config line, restart, and event_scheduler still shows OFF. This usually means MySQL is reading a different config file. Here's how to find the right one:
mysql --help | grep cnf # Linux
mysqld --verbose --help | findstr cnf # Windows
Look for lines like Default options are read from the following files. It lists them in order. The last one that has the [mysqld] section wins. Put your config there.
Another common cause: the event_scheduler variable is set to DISABLED (not just OFF). That's a compile-time option — you can't change it without rebuilding MySQL. Check with:
SHOW VARIABLES LIKE 'event_scheduler';
If it says DISABLED, you're stuck. You need to reinstall MySQL from a package that has event scheduler support (most stock packages do, but some minimal builds don't).
Check Permissions — Quick Detour
If events still don't run after enabling the scheduler, check if the event creator has the right privileges. Run:
SELECT user, host, event_priv FROM mysql.user WHERE user = 'your_event_user';
If event_priv is N, grant it:
GRANT EVENT ON *.* TO 'your_event_user'@'host';
Also check if the event itself is enabled:
SELECT name, status FROM mysql.event WHERE db = 'your_database';
status should be ENABLED. If SLAVESIDE_DISABLED, you've got a replication issue — the event only runs on the master.
Real-World Example
Last month, a client's MySQL 8.0 on Ubuntu 22.04 stopped running a purge job after a reboot. The fix? They had two my.cnf files — one in /etc/mysql/ and one in /etc/. The second one had event_scheduler=OFF and was being read last. Removing that line from the wrong file solved it.
Another case: a Windows Server 2019 with MySQL 5.7. The my.ini had the line under [mysqldump] by mistake. Moved it under [mysqld], restarted, events fired immediately.
Verify Events Are Running
Once the scheduler is on, check if events actually ran:
SELECT * FROM information_schema.EVENTS WHERE EVENT_SCHEMA = 'your_database' \G
Look at LAST_EXECUTED and STATUS. If STATUS is ENABLED and LAST_EXECUTED is recent, you're good.
Still broken? Check MySQL error logs — usually /var/log/mysql/error.log on Linux. Search for Event Scheduler or event. Sometimes the error is a syntax problem in the event body, not the scheduler itself.
The Short Version
1. Turn it on with SET GLOBAL event_scheduler = ON; — temporary test.
2. Add event_scheduler=ON under [mysqld] in the right config file — permanent fix.
3. Check permissions and event status if it's still broken.
That's it. You're done.