Mysql:my.cnf中的修改不生效

发布于 2024-12-28 19:15:27 字数 278 浏览 2 评论 0原文

我已使用以下行更新了数据库的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

白馒头 2025-01-04 19:15:27

确保 max_connections 在 [mysqld] 部分下:

例如:

[mysqld]
socket=/path/to/mysql.sock
datadir=/var/lib/mysql
max_connections=200

[client]
#mysql-client settings here..

Make sure the max_connections in under the [mysqld] section:

Ex:

[mysqld]
socket=/path/to/mysql.sock
datadir=/var/lib/mysql
max_connections=200

[client]
#mysql-client settings here..
喜爱纠缠 2025-01-04 19:15:27

尝试运行 mysqld --verbose --help 来查看 mysqld 实际读取了哪个配置文件以及使用了哪些参数和值。
输出将如下所示:

mysqld  Ver 5.0.51a-24-log for debian-linux-gnu on x86_64 ((Debian))
Copyright (C) 2000 MySQL AB, by Monty and others
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license

Default options are read from the following files in the given order:
/etc/mysql/my.cnf ~/.my.cnf /usr/etc/my.cnf
The following groups are read: mysql_cluster mysqld server mysqld-5.0

Variables (--variable-name=value)
and boolean options {FALSE|TRUE}  Value (after reading options)
--------------------------------- -----------------------------
...

To see what values a running MySQL server is using, type
'mysqladmin variables' instead of 'mysqld --verbose --help'.

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  Ver 5.0.51a-24-log for debian-linux-gnu on x86_64 ((Debian))
Copyright (C) 2000 MySQL AB, by Monty and others
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license

Default options are read from the following files in the given order:
/etc/mysql/my.cnf ~/.my.cnf /usr/etc/my.cnf
The following groups are read: mysql_cluster mysqld server mysqld-5.0

Variables (--variable-name=value)
and boolean options {FALSE|TRUE}  Value (after reading options)
--------------------------------- -----------------------------
...

To see what values a running MySQL server is using, type
'mysqladmin variables' instead of 'mysqld --verbose --help'.

回眸一笑 2025-01-04 19:15:27

对 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!

鸠魁 2025-01-04 19:15:27

这可能与 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.

别闹i 2025-01-04 19:15:27

如果 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.

温柔女人霸气范 2025-01-04 19:15:27

将 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文