PDF (A4) - 41.3Mb
Man Pages (TGZ) - 262.8Kb
Man Pages (Zip) - 368.8Kb
Info (Gzip) - 4.1Mb
Info (Zip) - 4.1Mb
Events are executed by a specialevent scheduler thread; when we refer to the Event Scheduler, we actually refer to this thread. When running, the event scheduler thread and its current state can be seen by users having thePROCESS privilege in the output ofSHOW PROCESSLIST, as shown in the discussion that follows.
The globalevent_scheduler system variable determines whether the Event Scheduler is enabled and running on the server. It has one of the following values, which affect event scheduling as described:
ON: The Event Scheduler is started; the event scheduler thread runs and executes all scheduled events.ONis the defaultevent_schedulervalue.When the Event Scheduler is
ON, the event scheduler thread is listed in the output ofSHOW PROCESSLISTas a daemon process, and its state is represented as shown here:mysql> SHOW PROCESSLIST\G*************************** 1. row *************************** Id: 1 User: root Host: localhost db: NULLCommand: Query Time: 0 State: NULL Info: show processlist*************************** 2. row *************************** Id: 2 User: event_scheduler Host: localhost db: NULLCommand: Daemon Time: 3 State: Waiting for next activation Info: NULL2 rows in set (0.00 sec)Event scheduling can be stopped by setting the value of
event_schedulertoOFF.OFF: The Event Scheduler is stopped. The event scheduler thread does not run, is not shown in the output ofSHOW PROCESSLIST, and no scheduled events execute.When the Event Scheduler is stopped (
event_schedulerisOFF), it can be started by setting the value ofevent_schedulertoON. (See next item.)DISABLED: This value renders the Event Scheduler nonoperational. When the Event Scheduler isDISABLED, the event scheduler thread does not run (and so does not appear in the output ofSHOW PROCESSLIST). In addition, the Event Scheduler state cannot be changed at runtime.
If the Event Scheduler status has not been set toDISABLED,event_scheduler can be toggled betweenON andOFF (usingSET). It is also possible to use0 forOFF, and1 forON when setting this variable. Thus, any of the following 4 statements can be used in themysql client to turn on the Event Scheduler:
SET GLOBAL event_scheduler = ON;SET @@GLOBAL.event_scheduler = ON;SET GLOBAL event_scheduler = 1;SET @@GLOBAL.event_scheduler = 1;Similarly, any of these 4 statements can be used to turn off the Event Scheduler:
SET GLOBAL event_scheduler = OFF;SET @@GLOBAL.event_scheduler = OFF;SET GLOBAL event_scheduler = 0;SET @@GLOBAL.event_scheduler = 0; If the Event Scheduler is enabled, enabling thesuper_read_only system variable prevents it from updating event“last executed” timestamps in theevents data dictionary table. This causes the Event Scheduler to stop the next time it tries to execute a scheduled event, after writing a message to the server error log. (In this situation theevent_scheduler system variable does not change fromON toOFF. An implication is that this variable rejects the DBAintent that the Event Scheduler be enabled or disabled, where its actual status of started or stopped may be distinct.). Ifsuper_read_only is subsequently disabled after being enabled, the server automatically restarts the Event Scheduler as needed.
AlthoughON andOFF have numeric equivalents, the value displayed forevent_scheduler bySELECT orSHOW VARIABLES is always one ofOFF,ON, orDISABLED.DISABLED has no numeric equivalent. For this reason,ON andOFF are usually preferred over1 and0 when setting this variable.
Note that attempting to setevent_scheduler without specifying it as a global variable causes an error:
mysql< SET @@event_scheduler = OFF;ERROR 1229 (HY000): Variable 'event_scheduler' is a GLOBALvariable and should be set with SET GLOBAL It is possible to set the Event Scheduler toDISABLED only at server startup. Ifevent_scheduler isON orOFF, you cannot set it toDISABLED at runtime. Also, if the Event Scheduler is set toDISABLED at startup, you cannot change the value ofevent_scheduler at runtime.
To disable the event scheduler, use one of the following two methods:
As a command-line option when starting the server:
--event-scheduler=DISABLEDIn the server configuration file (
my.cnf, ormy.inion Windows systems), include the line where it can be read by the server (for example, in a[mysqld]section):event_scheduler=DISABLED
To enable the Event Scheduler, restart the server without the--event-scheduler=DISABLED command-line option, or after removing or commenting out the line containingevent-scheduler=DISABLED in the server configuration file, as appropriate. Alternatively, you can useON (or1) orOFF (or0) in place of theDISABLED value when starting the server.
You can issue event-manipulation statements whenevent_scheduler is set toDISABLED. No warnings or errors are generated in such cases (provided that the statements are themselves valid). However, scheduled events cannot execute until this variable is set toON (or1). Once this has been done, the event scheduler thread executes all events whose scheduling conditions are satisfied.
Starting the MySQL server with the--skip-grant-tables option causesevent_scheduler to be set toDISABLED, overriding any other value set either on the command line or in themy.cnf ormy.ini file (Bug #26807).
For SQL statements used to create, alter, and drop events, seeSection 27.5.3, “Event Syntax”.
MySQL provides anEVENTS table in theINFORMATION_SCHEMA database. This table can be queried to obtain information about scheduled events which have been defined on the server. SeeSection 27.5.4, “Event Metadata”, andSection 28.3.14, “The INFORMATION_SCHEMA EVENTS Table”, for more information.
For information regarding event scheduling and the MySQL privilege system, seeSection 27.5.6, “The Event Scheduler and MySQL Privileges”.
PDF (A4) - 41.3Mb
Man Pages (TGZ) - 262.8Kb
Man Pages (Zip) - 368.8Kb
Info (Gzip) - 4.1Mb
Info (Zip) - 4.1Mb