{"id":189,"date":"2018-05-25T00:47:27","date_gmt":"2018-05-25T05:47:27","guid":{"rendered":"http:\/\/hconde.com\/wp\/?p=185"},"modified":"2019-02-24T04:44:34","modified_gmt":"2019-02-24T04:44:34","slug":"mysql-event-scheduler","status":"publish","type":"post","link":"https:\/\/horazmakes.com\/blog\/2018\/05\/25\/mysql-event-scheduler\/","title":{"rendered":"MySQL Event Scheduler"},"content":{"rendered":"<p><strong>Enable the MySQL Event Scheduler<\/strong><\/p>\n<ul>\n<li>Log in to your MySQL database as root (if necessary, connect to the server first)\n<ul>\n<li>ssh user@host<\/li>\n<\/ul>\n<\/li>\n<li>Verify if event_scheduler is enabled by connecting to mysql server and executing&nbsp;<strong>SHOW PROCESSLIST<\/strong> command.\n<ul>\n<li>mysql -h localhost -u root -p<\/li>\n<li>SHOW PROCESSLIST;<\/li>\n<\/ul>\n<\/li>\n<li>If the event scheduler is not enabled, add&nbsp;<strong>event_scheduler = ON<\/strong>&nbsp;to MySQL configuration file,&nbsp;at the [mysqld] section\n<ul>\n<li>sudo vi \/etc\/mysql\/my.cnf<\/li>\n<\/ul>\n<\/li>\n<li>&nbsp;Restart the MySQL server, for the changes to take effect\n<ul>\n<li>sudo \/etc\/init.d\/mysql stop<\/li>\n<li>sudo \/etc\/init.d\/mysql start<\/li>\n<\/ul>\n<\/li>\n<li>event_scheduler should now be enabled, check through <strong>SHOW PROCESSLIST<\/strong> command, again\n<ul>\n<li>mysql&gt; SHOW PROCESSLIST;<br \/>\n+&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br \/>\n| Id | User | Host | db | Command | Time | State | Info |<br \/>\n+&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br \/>\n| 1 | event_scheduler | localhost | NULL | Daemon | 18 | Waiting on empty queue | NULL |<br \/>\n| 38 | root | localhost | NULL | Query | 0 | NULL | SHOW PROCESSLIST |<br \/>\n+&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br \/>\n2 rows in set (0.00 sec)<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>Creating an Event<\/strong><\/p>\n<p><a href=\"https:\/\/dev.mysql.com\/doc\/refman\/5.7\/en\/create-event.html\">https:\/\/dev.mysql.com\/doc\/refman\/5.7\/en\/create-event.html<\/a><\/p>\n<p>Example:<\/p>\n<pre class=\"lang:default decode:true \">CREATE EVENT myevent\n    ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR\n    DO\n      UPDATE myschema.mytable SET mycol = mycol + 1;<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Enable the MySQL Event Scheduler Log in to your MySQL database as root (if necessary, connect to the server first) ssh user@host Verify if event_scheduler is enabled by connecting to mysql server and executing&nbsp;SHOW PROCESSLIST command. mysql -h localhost -u root -p SHOW PROCESSLIST; If the event scheduler is not enabled, add&nbsp;event_scheduler = ON&nbsp;to MySQL [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":257,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,86],"tags":[91,88,90,87,89],"class_list":["post-189","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mysql","category-programming","tag-event","tag-event-scheduler","tag-job","tag-mysql","tag-scheduler"],"_links":{"self":[{"href":"https:\/\/horazmakes.com\/blog\/wp-json\/wp\/v2\/posts\/189","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/horazmakes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/horazmakes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/horazmakes.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/horazmakes.com\/blog\/wp-json\/wp\/v2\/comments?post=189"}],"version-history":[{"count":1,"href":"https:\/\/horazmakes.com\/blog\/wp-json\/wp\/v2\/posts\/189\/revisions"}],"predecessor-version":[{"id":260,"href":"https:\/\/horazmakes.com\/blog\/wp-json\/wp\/v2\/posts\/189\/revisions\/260"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/horazmakes.com\/blog\/wp-json\/wp\/v2\/media\/257"}],"wp:attachment":[{"href":"https:\/\/horazmakes.com\/blog\/wp-json\/wp\/v2\/media?parent=189"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/horazmakes.com\/blog\/wp-json\/wp\/v2\/categories?post=189"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/horazmakes.com\/blog\/wp-json\/wp\/v2\/tags?post=189"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}