gpt4 book ai didi

mysql - 为什么这个 mysql 事件无法运行?

转载 作者:IT老高 更新时间:2023-10-29 00:05:13 25 4
gpt4 key购买 nike

mysql> show create event online_event;
+--------------+-----------------------------------------+-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+--------------------+
| Event | sql_mode | time_zone | Create Event | character_set_client | collation_connection | Database Collation |
+--------------+-----------------------------------------+-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+--------------------+
| online_event | STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER | SYSTEM | CREATE EVENT `online_event` ON SCHEDULE EVERY 1 SECOND STARTS '2009-06-03 06:54:16' ON COMPLETION NOT PRESERVE ENABLE DO DELETE FROM online where webserver_id is null and jabber_server_id is null | utf8 | utf8_general_ci | utf8_general_ci |
+--------------+-----------------------------------------+-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+--------------------+
1 row in set (0.00 sec)

mysql>

它是这样创建的:

CREATE EVENT online_event
ON SCHEDULE EVERY 1 SECOND
DO
DELETE FROM online where webserver_id is null and jabber_server_id is null;

经过一段时间后,我发现:

mysql> select *from online;
+----+------------+---------------------+--------------+------------------+
| id | account_id | since | webserver_id | jabber_server_id |
+----+------------+---------------------+--------------+------------------+
| 1 | 30 | 2009-06-03 06:24:38 | NULL | NULL |
+----+------------+---------------------+--------------+------------------+
1 row in set (0.00 sec)

所以我发现这个事件根本就没有运行。

最佳答案

您的事件调度程序是否正在运行?检查 SHOW PROCESSLIST

如果用户“event_scheduler”没有进程“守护进程”,则它没有运行。

因此启动事件调度程序:

SET GLOBAL event_scheduler = ON;

另见 http://dev.mysql.com/doc/refman/5.1/en/events-configuration.html

关于mysql - 为什么这个 mysql 事件无法运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/942354/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com