即使 MySQL 重新启动,如何设置全局 event_scheduler=ON?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20112395/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 19:29:14  来源:igfitidea点击:

How to set global event_scheduler=ON even if MySQL is restarted?

mysqleventsscheduler

提问by nakul

I want to set the event_schedulerglobal to ONeven if MySQL is restarted; how can I achieve this?

我想将event_scheduler全局设置为ON即使 MySQL 重新启动;我怎样才能做到这一点?

SET GLOBAL event_scheduler = ON;

采纳答案by Suleman Ahmad

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

一种方法 - 如果有可能重新启动 mysql,您可以设置系统变量并使用这些变量。

Here is link Using system variables in mysql

这是在mysql中使用系统变量的链接

回答by prem

You can set

你可以设置

event_scheduler=ON

in my.inior my.cnffile, then restart your server for the setting to take effect.

my.inimy.cnf文件中,然后重新启动服务器以使设置生效。

Once set event_schedulerwill always remain ONno matter whether your server restarts.

无论您的服务器是否重新启动,一旦设置event_scheduler将始终保留ON

回答by Francesco Borzi

Open your /etc/mysql/my.inifile and add:

打开您的/etc/mysql/my.ini文件并添加:

event_scheduler = on

under the [mysqld]section

[mysqld]部分下

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

(在 mysql 5.5.35-0+wheezy1 - Debian 下测试)

回答by Mark Bondurant

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

在我们的 Windows Server 2012 系统上,这些或任何其他解决方案都不起作用。然后我查看了启动的注册表项:

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

"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.inifile, put there just to royally screw you up.

诡计,邪恶,是ProgramData。不是Program Files。查看程序文件,你会看到一个my-default.ini文件,放在那里只是为了把你搞砸。

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

诀窍是在注册表中找到路径,这对我来说是: HKEY_LOCAL_MACHINE\SYSTEM\Services\MySQL56

回答by Roberts Lando

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 bash:

mysql -u <user> -p

Than run the command:

比运行命令:

SHOW PROCESSLIST;

Now you should see the event scheduler daemon in the list

现在您应该在列表中看到事件调度程序守护进程