参阅https://www.cnblogs.com/baiyb/p/9281517.html
参阅https://blog.csdn.net/zwlsuperman/article/details/81333890
总结:
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
附
还遇见了其它说法,apt、yum、rpm 方式安装的mysql在对max_connection的限制也不同。