38

I want to set the event_scheduler global to ON even if MySQL is restarted; how can I achieve this?

SET GLOBAL event_scheduler = ON;
Danny Beckett
  • 20,529
  • 24
  • 107
  • 134
nakul
  • 503
  • 1
  • 7
  • 17
  • one way - you can set system variables, and use those variables whenever needed (http://dev.mysql.com/doc/refman/5.0/en/using-system-variables.html). – Suleman Ahmad Nov 21 '13 at 04:52

5 Answers5

49

You can set

event_scheduler=ON

in my.ini or my.cnf file, then restart your server for the setting to take effect.

Once set event_scheduler will always remain ON no matter whether your server restarts.

Christian Giupponi
  • 7,408
  • 11
  • 68
  • 113
prem
  • 3,348
  • 1
  • 25
  • 57
  • 1
    On my case (Ubuntu 14.04.4 LTS), adding it to `/etc/mysql/my.cnf` did the trick, while adding it to `/etc/mysql/my.ini` did nothing. – cavpollo Nov 04 '16 at 21:11
  • 1
    On a Windows machine with MySQL 5.7, `event-scheduler=on` worked for me – Ananth Jun 02 '17 at 12:08
  • 4
    Make sure you add the setting into the proper section - it should go under `[mysqld]`. Otherwise the server won't be able to start... – AntonK Sep 25 '18 at 15:44
  • And of course you have to put it into the right file. I had two files, one `D:\MariaDB\my.ini` and one `D:\MariaDB\data\my.ini` . Not sure why but during the installation the latter one was the one which is used. – Anse Feb 26 '19 at 10:58
  • on an Amazon Linux AMI image, it worked by modifying the /etc/my.cfg file. Thanks! – Graph Jan 13 '20 at 22:40
31

Open your /etc/mysql/my.ini file and add:

event_scheduler = on

under the [mysqld] section

(tested under mysql 5.5.35-0+wheezy1 - Debian)

Francesco Borzi
  • 56,083
  • 47
  • 179
  • 252
4

One Way - You can set your system variables and use those variables if there is any possibility to restart your mysql.

Here is link Using system variables in mysql

Suleman Ahmad
  • 2,025
  • 4
  • 28
  • 43
  • 3
    "If you change a global system variable, the value is remembered and used for new connections until the server restarts. (To make a global system variable setting permanent, you should set it in an option file)" – mvmn Jan 21 '16 at 19:02
4
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf 

Add this line at the end of the file:

event_scheduler=ON

Than reboot and check if daemon is started after reboot:

Log into mysql bash:

mysql -u <user> -p

Than run the command:

SHOW PROCESSLIST;

Now you should see the event scheduler daemon in the list

3

On our Windows Server 2012 system, none of these or any other solutions worked. Then I looked at the registry entry for start up:

"C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqld.exe" --defaults-file="C:\ProgramData\MySQL\MySQL Server 5.6\my.ini" MySQL56

The trick, the evil, is ProgramData. It's not Program Files. Look in Program Files and you'll see a my-default.ini file, put there just to royally screw you up.

The trick is to find the path in the registry, which was for me: HKEY_LOCAL_MACHINE\SYSTEM\Services\MySQL56

mins
  • 6,478
  • 12
  • 56
  • 75