2009-06-02 18 views
13
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> 

Se crea de esta manera:¿por qué este evento mysql no se puede ejecutar?

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

y después de un período bastante, encontré:

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) 

Así que me parece que el evento no se ejecuta en absoluto.

Respuesta

41

¿Está funcionando su planificador de eventos? Consulte con SHOW PROCESSLIST.

Si no tiene un proceso "Daemon" por el usuario "event_scheduler", no se está ejecutando.

iniciar el planificador de eventos de este modo:

SET GLOBAL event_scheduler = ON; 

Ver también http://dev.mysql.com/doc/refman/5.1/en/events-configuration.html

+0

pero cuando reinicio el servidor que no se inicia automáticamente –

+0

cuando pongo la línea 'event_scheduler = ENABLED' en el fichero' my.conf' el servicio no se inicia –

+15

Tuve que insertar la línea 'event_scheduler = ON' en la sección' [mysqld] 'del archivo' my.conf' –

Cuestiones relacionadas