MySQL 如何在不重启的情况下刷新MySQL配置文件?

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

How do you refresh the MySQL configuration file without restarting?

mysqldatabase

提问by omg

Apache has such a feature, what about MySQL?

Apache有这样的功能,那MySQL呢?

Does one exist?

一个存在吗?

回答by mixonic

You were so close! The kill -HUPmethod wasn't working for me either.

你离得太近了!该kill -HUP方法对我也不起作用。

You were calling:

你打电话给:

select @@global.max_connections;

All you needed was to set instead of select:

您所需要的只是设置而不是选择:

set @@global.max_connections = 400;

See:

看:

http://www.netadmintools.com/art573.html

http://www.netadmintools.com/art573.html

http://www.electrictoolbox.com/update-max-connections-mysql/

http://www.electrictoolbox.com/update-max-connections-mysql/

回答by Jon

Try:

尝试:

sudo /etc/init.d/mysql reload

or

或者

sudo /etc/init.d/mysql force-reload

That should initiate a reload of the configuration. Make sureyour init.d script supports it though, I don't know what version of MySQL/OS you are using?

这应该启动配置的重新加载。确保您的 init.d 脚本支持它,但我不知道您使用的是什么版本的 MySQL/OS?

My MySQL script contains the following:

我的 MySQL 脚本包含以下内容:

'reload'|'force-reload')
        log_daemon_msg "Reloading MySQL database server" "mysqld"
        $MYADMIN reload
        log_end_msg 0
        ;;

回答by Rick James

Reloading the configuration file (my.cnf) cannot be done without restarting the mysqldserver.

my.cnf如果不重新启动mysqld服务器,则无法重新加载配置文件 ( ) 。

FLUSH LOGSonly rotates a few log files.

FLUSH LOGS只轮换几个日志文件。

SET @@...=...sets it for anyone not yet logged in, but it will go away after the next restart. But that gives a clue... Do the SET, andchange my.cnf; that way you are covered. Caveat: Not all settings can be performed via SET.

SET @@...=...为尚未登录的任何人设置它,但它会在下次重新启动后消失。但这给出了一个线索......做SET改变my.cnf; 这样你就被覆盖了。警告:并非所有设置都可以通过SET.

New with MySQL 8.0...

MySQL 8.0 新...

SET PERSIST ...will set the global setting andsave it past restarts. Nearly all settings can be adjusted this way.

SET PERSIST ...将设置全局设置并将其保存到重新启动后。几乎所有设置都可以通过这种方式进行调整。

回答by user6007326

Specific actions you can do from SQL client and you don't need to restart anything:

您可以从 SQL 客户端执行的特定操作,您无需重新启动任何操作:

SET GLOBAL log = 'ON';
FLUSH LOGS;