- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to set global event_scheduler=ON even if MySQL is restarted?
There is a single way by which you can set a global event_scheduler=ON even if MySQL is restarted. You need to set global system variable ON and need to use this system variable even if MySQL restart.
For this, I am using system variable @@event_scheduler using select statement. The query is as follows:
mysql> select @@event_scheduler;
The following is the output:
+-------------------+ | @@event_scheduler | +-------------------+ | ON | +-------------------+ 1 row in set (0.00 sec)
Now, restart MySQL. The query is as follows:
mysql> restart; Query OK, 0 rows affected (0.00 sec)
After restarting the server the connection is lost for some time. If you use any query you will get the following error message:
mysql> select @@event_scheduler; ERROR 2013 (HY000): Lost connection to MySQL server during query
After some time if you will use the system variable @@event_scheduler again using select statement, then the output you will get the same i.e. ON. The query is as follows:
mysql> select @@event_scheduler; ERROR 2006 (HY000): MySQL server has gone away No connection. Trying to reconnect... Connection id: 8 Current database: *** NONE *** +-------------------+ | @@event_scheduler | +-------------------+ | ON | +-------------------+ 1 row in set (0.04 sec)
Or you can set the event_scheduler ON in my.cnf file or my.ini file. The statement is as follows:
[mysqld] event_scheduler = ON;
Now your event_scheduler is ON. Whether your server restarts or not, it will always be ON.