Event Scheduler 在后台运行并管理计划事件的执行。事件调度器用于调度在指定时间和间隔内在 MySQL 数据库中执行的作业和任务。
启用事件调度程序
SET GLOBAL event_scheduler = ON; SET @@GLOBAL.event_scheduler = ON; SET GLOBAL event_scheduler = 1; SET @@GLOBAL.event_scheduler = 1;
禁用事件调度程序:
SET GLOBAL event_scheduler = OFF; SET @@GLOBAL.event_scheduler = OFF; SET GLOBAL event_scheduler = 0; SET @@GLOBAL.event_scheduler = 0;
在 my.cnf 或 my.ini 配置文件中启用或禁用:
For enable, use as comment
—event_scheduler=DISABLED
—For Disable, remove comment — event_scheduler=DISABLED
验证 Event Scheduler 服务是否正在运行:
SHOW PROCESSLIST;
mysql> show processlist;
+----+-----------------+-----------------+------+---------+--------+------------------------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+-----------------+-----------------+------+---------+--------+------------------------+------------------+
| 5 | event_scheduler | localhost | NULL | Daemon | 175650 | Waiting on empty queue | NULL |
| 8 | root | localhost:63048 | NULL | Query | 0 | init | show processlist |
+----+-----------------+-----------------+------+---------+--------+------------------------+------------------+
2 rows in set (0.00 sec)
参考文章
https://smarttechways.com/2021/06/17/enable-and-disable-event-scheduler-in-mysql/