6

How do I turn on the event scheduler in mysqld permanently? I'm using phpMyAdmin and I have scheduled an event to copy records from one table to another everyday at a specific time, but the records are not being copied everyday. I've tried setting the event scheduler on.

SET GLOBAL event_scheduler="ON"; 

When I restart my pc, the event scheduler is turned off. How do I make it be always on, and not turned off when mysqld is restarted?

8

This is quite an easy one really (one of those "Doh" moments :-) ).

You set it in my.cnf as described here:

[mysqld]
..
.. other_stuff
..
event_scheduler=on
..
.. more_stuff
..

(or my.ini if you're running Windows as pointed out below)

From the MySQL documentation here, you have:

When the Event Scheduler is ON, the event scheduler thread is listed in the output of SHOW PROCESSLIST as a daemon process, and its state is represented as shown here:

A daemon process is one that runs in the background as described here. Also known as a service in Windows

So, run:

mysql> SHOW PROCESSLIST\G

and there should be an entry like this:

*************************** 2. row ***************************
     Id: 2
   User: event_scheduler
   Host: localhost
     db: NULL
Command: Daemon      <<<<<====== Note: Daemon!!!
   Time: 3
  State: Waiting for next activation
   Info: NULL
2 rows in set (0.00 sec)
1
  • A slight addition to @Verace's answer for clarification for newbies whom might be working locally on window platform such as laragon, you will need to find and edit "my.ini" in MySql, because Laragon dont have my.cnf Aug 7 '19 at 16:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.