Reputation: 49150
In MySQL, we can enable the event scheduler by following query:
SET GLOBAL event_scheduler = ON;
Similarly, to turn off the scheduler:
SET GLOBAL event_scheduler = OFF;
But, Is there any query/way to check the status of event_scheduler
whether it's ON
or OFF
?
Upvotes: 39
Views: 81757
Reputation: 1
With the SQL below, you can check event_scheduler
's status. *The doc explains event_scheduler
global varialbe:
mysql> SELECT @@GLOBAL.event_scheduler;
+--------------------------+
| @@GLOBAL.event_scheduler |
+--------------------------+
| ON |
+--------------------------+
And with the SQL below, you can also check event_scheduler
's status. *The doc explains SHOW VARIABLES
statement:
mysql> SHOW VARIABLES WHERE VARIABLE_NAME = 'event_scheduler';
+-----------------+----------------+
| VARIABLE_NAME | VARIABLE_VALUE |
+-----------------+----------------+
| event_scheduler | ON |
+-----------------+----------------+
In addition, with the SQL below, you can also check if event_scheduler
is ON
or OFF
. *If event_scheduler
is ON
, event_scheduler
appears and if event_scheduler
is OFF
, event_scheduler
doesn't appear and the doc explains SHOW PROCESSLIST
statement:
SHOW PROCESSLIST;
Or:
SHOW FULL PROCESSLIST;
Upvotes: 0
Reputation: 550
Use below command to see event status , you can choose any of them.
SELECT @@global.event_scheduler
or
SHOW variables WHERE variable_name ='event_scheduler'
To enable event temporarily ON or OFF
SET GLOBAL event_scheduler = OFF;
SET GLOBAL event_scheduler = ON;
For permanent setup go to my.cnf or my.ini or inside /etc/my.cnf.d/server.cnf file and under [mysqld] set event_scheduler =ON or event_scheduler=OFF depending on your requirements.
Upvotes: 9
Reputation: 8995
This should also work:
select @@global.event_scheduler = 'ON'
That is a little easier to use in a stored procedure, where you might want to know if it is ON before turning it on. Note that I tested this on MySQL 5.7 after turning on Event_Scheduler either with ON or 1. In both cases, querying the variable returns 'ON'.
Also, note the quotes are used for querying, but not for setting the variable. A little mysql weirdness for you.
Upvotes: 3
Reputation: 10143
Use SHOW VARIABLES
SHOW VARIABLES
WHERE VARIABLE_NAME = 'event_scheduler'
Upvotes: 60