Broad Network


MySQL Event Scheduler

Event in MySQL – Part 4

Forward: In this part of the series, I explain the meaning and use of MySQL Event Scheduler.

By: Chrysanthus Date Published: 4 Sep 2012

Introduction

This is part 4 of my series, Event in MySQL. In this part of the series, I explain the meaning and use of MySQL Event Scheduler. I assume you have read the previous parts of the series, because this is a continuation.

Before an Event Operates
Before you can create an event, you must have been given the Event privilege. With that you can create, alter and drop events. However, the events will still not operate if the event scheduler is turned off or disabled.

The Event Scheduler
The event scheduler is a piece of code of the MySQL server that controls events. It can be turned on. If it is on, all events operate as expected. If it is off or disabled, the events cannot operate.

Three States
The event scheduler has 3 states. It can be Off, On or Disabled.
Off: When the event scheduler is off (stopped), it means the code of the event scheduler is not running. Under this condition all events do not operate. The Off state is the default state.
On: When the event scheduler is on (started) it means the code of the event scheduler is running and the event scheduler is executing the events (making the events run as well).
Disabled: This is similar to the Off state. When the event scheduler is turned off, it can be turned on again while the server is still running. However, when the scheduler is disabled, it can only be turned on again after the MySQL server has restarted (or when the server is restarting).

Turning On the Event Scheduler
With the MySQL client program, any of the following statements can be used 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;

Turning Off the Event Scheduler
With the MySQL client program, any of the following 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;

While the server is running, you can turn the event scheduler on and turn it off.

Disabling the Event Scheduler
The event scheduler can be disabled at server start up with the following command line option:

    --event-scheduler=DISABLED

In my windows operating system, the following is what I would type at the command prompt (DOS) window:

    "C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld" --console --event-scheduler=DISABLED

Restarting and Turning On
If you restart the MySQL server without the “--event-scheduler=DISABLED” option, the event scheduler will be off. It can then be turned on as illustrated above. Remember, for the events to operate the event scheduler has to be on. Do not forget that in order to create, alter and drop events, you need the event privilege, as well. The system administrator has all the privileges and can grant to you the coder, any of the privileges.

End of Tutorial – End of Series – End of Volume
This is the end of the tutorial. This is the end of the series. And this is the end of the Volume. I hope you appreciated the volume.

I advice you to give yourself projects and carry them out. Or you can join the following network and be trying the projects that are issued, without applying for them. You should also learn other programming courses. When you are confident, you can start applying for the projects. The network link is given below.

Good Luck!

Chrys

Programming Solutions

Comments

Become the Writer's Fan
Send the Writer a Message