Mysql:my.cnf中的修改不生效
我已使用以下行更新了数据库的 my.cnf
文件:max_connections=200
。之后我停止并启动 mysql 服务以使更改生效。
但由于某种原因,此更改不会影响数据库,因为如果我运行:
mysql> select @@max_connections
它显示最大连接数为 100。
显然还有其他地方管理此值。我在哪里可以找到它或者我做错了什么?
感谢你的回复。
I've updated the my.cnf
file of my database with the following line: max_connections=200
. I stopped and started the mysql service after that so that the changes would take effect.
But for some reason this change doesn't affect the database because if I run:
mysql> select @@max_connections
it shows that the max number of connections is 100.
Obviously there is some place else that manages this value. Where can I find it or what did I do wrong?
Thank you for your reply.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
确保 max_connections 在 [mysqld] 部分下:
例如:
Make sure the max_connections in under the [mysqld] section:
Ex:
尝试运行 mysqld --verbose --help 来查看 mysqld 实际读取了哪个配置文件以及使用了哪些参数和值。
输出将如下所示:
Try running
mysqld --verbose --help
to see which configuration file is actually read by mysqld and which parameters and values are used.The output will look like this:
对 mysqld 的更改不一定反映在 mysql 客户端中!我在my.cnf中更改了一个全局变量赋值,重新启动服务,并在mysql客户端中查询它。它返回旧值。然而,当从脚本查询时,该值实际上已更改!
Changes to mysqld are not necessarily reflected in the mysql client! I changed a global variable assignment in my.cnf, restarted the service, and queried it in the mysql client. It returned the old value. When queried from a script, however, the value was in fact changed!
这可能与 mysql 服务器“如何”关闭和重新启动有关。在我的系统上,如果我使用 mysqld 守护进程服务关闭 mysql(例如 service mysqld stop),我会收到关闭通知,但 ps 显示 mysql 仍在运行。使用类似的“service mysqld restart”,对 my.cnf 文件的一些更改会被接受,但许多更改不会被接受。
另一种关闭mysql的方法是使用mysqladmin -u user -pPass shutdown。我注意到当我使用这种方法时,mysql被完全关闭(ps中没有剩余),当我重新启动mysql服务器时,对my.cnf文件的所有更改都被接受。
It may have to do with 'how' the mysql server is being shutdown and restarted. On my system if I use the mysqld daemon service to shutdown mysql (e.g. service mysqld stop), I get a shutdown notice, but a ps shows mysql is still running. Using a similar 'service mysqld restart', some of the changes to the my.cnf file get accepted, but many don't.
The other method of shutting down mysql is to use mysqladmin -u user -pPass shutdown. I noticed when I used this method, mysql was shutdown completely (no left overs in ps), and when I restarted the mysql server, all the changes to the my.cnf file were accepted.
如果 mysql 作为 Windows 服务启动,请检查 Windows 服务上的“可执行文件路径”设置。 (服务 -> MYSQL56 -> 属性)。
如果传入 --defaults-file 选项,它可能会指向一个完全不同的 .ini 文件,该文件位于未通过“mysqld --verbose --help”显示的位置。
如果从服务启动参数中删除 --defaults-file 选项,它将遍历 mysqld --verbose --help 列出的 ini 文件列表。
If mysql starts as a Window service, check the 'Path to executable' setting on the windows service. (Services -> MYSQL56 -> Properties).
If the --defaults-file option is passed in, it could point to a completely different .ini file in a location that is NOT showing with 'mysqld --verbose --help'.
If you remove the --defaults-file option from the service startup parameters, it will go through the list of ini files as listed with mysqld --verbose --help.
将 my.cnf 放入 /etc/my.cnf 并重新启动 mysql 解决了我的问题。我正在使用 mac 操作系统。 Mysql版本是5.6.41
Putting my.cnf in /etc/my.cnf and restarting mysql has resolved the issue for me. I'm using mac os. Mysql version is 5.6.41