MySQL 如何让MySQL在不重启的情况下再次读取my.cnf?

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

How to make MySQL read my.cnf again without restarting?

mysql

提问by Mask

Is there such a command?

有这样的命令吗?

I've modified my.cnf,and I don't want to stop/start MySQL.

我已经修改了 my.cnf,我不想停止/启动 MySQL。

采纳答案by jochil

As far as I know you have to restart your MySQL Server, but there are some configuration variables that can changed without restarting: dynamic system variables

据我所知,您必须重新启动 MySQL 服务器,但有一些配置变量无需重新启动即可更改:动态系统变量

回答by Tim Post

As far as POSIX goes, SIGHUP(which normally tells a program designed to run in the background after starting to reload its config) flushes privileges. Reference here. That's actually as it should be, if you ran the service in the foreground and got disconnected, you'd probably want that to happen.

就 POSIX 而言,SIGHUP(通常告诉设计为在开始重新加载其配置后在后台运行的程序)刷新特权。参考这里。这实际上是应该的,如果您在前台运行服务并断开连接,您可能希望发生这种情况。

That leaves us with SIGUSR(1 or 2)which have been known to crashthe service.

这给我们留下了已知会导致服务崩溃SIGUSR(1 或 2)

In short, make due with the tools provided :) Any time you are dealing with a service that makes use of more than primitive IPC, its a good idea to just re-start the service when you make configuration changes. Lots of running threads need to complete their work, die and be re-born .. yet another race to a mutual exclusive lock would take more time than just re-starting it, considering that every running thread would have to modify its behavior and understanding of its universe in situ. That leads to deadlock, quickly and a zombie parent.

简而言之,使用所提供的工具进行支付 :) 任何时候您处理的服务使用的不仅仅是原始IPC,在您进行配置更改时重新启动服务是一个好主意。许多正在运行的线程需要完成它们的工作,死亡并重生……考虑到每个正在运行的线程都必须修改其行为和理解,因此另一场争夺互斥锁所需的时间不仅仅是重新启动它它的宇宙就地。这会迅速导致僵局和僵尸父母。

Keep in mind that most RDBMS use their own buffering, which is typically handled by the kernel for most other services. You can't just ask a thread to speak Spanish when it once spoke English, or vice versa, depending on what you changed in the configuration.

请记住,大多数 RDBMS 使用自己的缓冲,通常由内核处理大多数其他服务。您不能只要求线程在讲英语时讲西班牙语,反之亦然,这取决于您在配置中所做的更改。

At least, not without reincarnating the parent.. hence, just re-start.

至少,不是没有转世父母..因此,只需重新开始。

回答by Erik Osterman

Install the RubyGem mysql_manager(sudo gem install mysql_manager) and then run the command:

安装 RubyGem mysql_manager( sudo gem install mysql_manager) 然后运行命令:

mysql-manager --reload-my-cnf --reload-my-cnf:config /etc/my.cnf --log:level DEBUG

For more options, run mysql-manager --help.

如需更多选项,请运行mysql-manager --help.

You might need to specify an alternative --db:dsn, --db:username, or --db:password.

您可能需要指定替代--db:dsn--db:username--db:password

Read more about it here: https://github.com/osterman/mysql_manager

在此处阅读更多相关信息:https: //github.com/osterman/mysql_manager