在服务器重启时启用 mysql 事件调度程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10071871/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Enabling mysql Event scheduler on server restarts
提问by dames
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?
我正在运行 phpmyadmin 并在我的个人计算机上安装了 apache 服务器。我的问题是我试图将 MySQL 设置event_scheduler
为即使服务器重新启动也始终启用。我是通过在服务器配置文件(my.cnf
或my.ini
)中设置以下命令行来阅读它的,它应该可以工作:event_scheduler=DISABLED
. 但是,我在哪里可以找到此文件my.cnf
或my.ini
文件,还应该使用命令行event_scheduler=DISABLED
还是event_scheduler=ENABLED
查看我希望始终启用它?
回答by Devart
You should set 'ON' value (not ENABLED).
您应该设置“ON”值(未启用)。
In the configuration file in [mysqld] section specify 'event-scheduler' option (not event_scheduler).
在 [mysqld] 部分的配置文件中指定“event-scheduler”选项(不是 event_scheduler)。
Also, you can start your MySQL server with '--event-scheduler' option, e.g. -
此外,您可以使用“--event-scheduler”选项启动您的 MySQL 服务器,例如 -
shell> mysqld --event-scheduler=ON
shell> mysqld --event-scheduler=ON
More information - event_scheduler system variable.
更多信息 - event_scheduler 系统变量。
回答by netkiller
Add to my.cnf file to [mysqld] section.
将 my.cnf 文件添加到 [mysqld] 部分。
GLOBAL event_scheduler=ON
Restart your mysql server. Check status with this command :
重新启动您的 mysql 服务器。使用此命令检查状态:
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)
回答by Mohan Kumar
Here the path for my.ini
on XAMPP:
这是my.ini
XAMPP 上的路径:
xampp\mysql\bin\my.ini
Open my.ini
and add the following
打开my.ini
并添加以下内容
[mysqld]
event_scheduler=ON
then restart MySQL service.
然后重启MySQL服务。
To check the status use the below MySQL query:
要检查状态,请使用以下 MySQL 查询:
SELECT @@event_scheduler
回答by AndrewD
For WAMP:
对于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
;
编辑 my.ini 文件并在 [mysqld] 部分下添加以下内容:
event-scheduler=on
重启所有服务
通过运行此查询进行验证:
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'.
要访问 my.ini 文件,只需单击 WAMP 托盘图标并将鼠标悬停在“MySQL”菜单上,然后单击“my.ini”。
回答by Aurovrata
FOR MAMPon OS X:
FOR甲基苯丙胺在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,
默认安装不包含my.cnf
文件,因此您需要创建一个文件并设置默认配置。因此,要在 OS X MAMP 堆栈上启用调度程序,您需要:
- 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.
- 停止你的 MySQL 服务器
my.cnf
在您的/Applications/MAMP/conf/
文件夹中创建一个文件,您需要 root 访问权限才能执行此操作(打开终端窗口),须藤触摸/Applications/MAMP/conf/my.cnf
须藤纳米/Applications/MAMP/conf/my.cnf
第二个 cmd 将打开 nano 编辑器,将以下内容粘贴到您的文件中,
[mysqld]
event_scheduler=ON
保存 (
^O
) 并退出 (^X
) nano 编辑器重启你的 MySQL 服务器。