问题
I am running phpmyadmin and installed apache server on my personal computer. My problem is that I am trying to set MySQL event_scheduler
to always be enabled even when the server restarts. I was reading that by setting the following command line in the server configuration file (my.cnf
or my.ini
) it should work: event_scheduler=DISABLED
. However, where do I locate this my.cnf
or my.ini
file, and also should the command line be event_scheduler=DISABLED
or event_scheduler=ENABLED
seeing that I want it to always be enabled?
回答1:
You should set 'ON' value (not ENABLED).
In the configuration file in [mysqld] section specify 'event-scheduler' option (not event_scheduler).
Also, you can start your MySQL server with '--event-scheduler' option, e.g. -
shell> mysqld --event-scheduler=ON
More information - event_scheduler system variable.
回答2:
Add to my.cnf file to [mysqld] section.
GLOBAL event_scheduler=ON
Restart your mysql server. Check status with this command :
mysql> select @@GLOBAL.event_scheduler;
+--------------------------+
| @@GLOBAL.event_scheduler |
+--------------------------+
| ON |
+--------------------------+
1 row in set (0.00 sec)
mysql> SHOW VARIABLES LIKE 'event_scheduler';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| event_scheduler | ON |
+-----------------+-------+
1 row in set (0.01 sec)
回答3:
Here the path for my.ini
on XAMPP:
xampp\mysql\bin\my.ini
Open my.ini
and add the following
[mysqld]
event_scheduler=ON
then restart MySQL service.
To check the status use the below MySQL query:
SELECT @@event_scheduler
回答4:
For WAMP:
Edit your my.ini file and under the [mysqld] section, add this:
event-scheduler=on
restart all services
verify by running this query:
select @@event_scheduler
;
To get to your my.ini file, just click the WAMP tray icon and hover over the 'MySQL' menu, and click 'my.ini'.
回答5:
FOR MAMP on OS X:
the default installation does not include a my.cnf
file so you need to create one and set up your default configuration. Therefore, to enable the the scheduler on an OS X MAMP stack, you need to,
- stop your MySQL server
create a
my.cnf
file in your/Applications/MAMP/conf/
folder, you will need root access to do this (open a terminal window),sudo touch /Applications/MAMP/conf/my.cnf
sudo nano /Applications/MAMP/conf/my.cnf
the 2nd cmd will open the nano editor, paste the following in your file,
[mysqld]
event_scheduler=ON
Save (
^O
) and exit (^X
) the nano editorrestart your MySQL server.
来源:https://stackoverflow.com/questions/10071871/enabling-mysql-event-scheduler-on-server-restarts