1.设置mysql最大连接数问题

设置mysql最大连接数问题

只修改 /etc/mysql/my.cnf不生效

[mysqld]

max_connections=1001

主要是mysql 的 max_connections 参数 和本身操作系统的open-file-limit有关。

官方文档描述为

The maximum number of connections MySQL can support depends on the quality of the thread library on a given platform, the amount of RAM available, how much RAM is used for each connection, the workload from each connection, and the desired response time. Increasing open-files-limit may be necessary. Also see Section 2.5, “Installing MySQL on Linux”, for how to raise the operating system limit on how many handles can be used by MySQL.

以下解决不生产问题

1.修改/etc/security/limits.conf,添加

root soft nofile 65535

root hard nofile 65535

* soft nofile 65535

* hard nofile 65535

2.修改/lib/systemd/system/mysql.service,添加

LimitNOFILE=65535

LimitNPROC=65535

(注:此处路径可能与系统有关, 若不在 /lib/systemd/system 路径下可以确认是否存在于 /usr/lib/systemd/system 路径下)


3、执行命令

systemctl daemon-reload

systemctl restart mysql.service

最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
禁止转载,如需转载请通过简信或评论联系作者。

相关阅读更多精彩内容

友情链接更多精彩内容