- 工信部备案号 滇ICP备05000110号-1
- 滇公安备案 滇53010302000111
- 增值电信业务经营许可证 B1.B2-20181647、滇B1.B2-20190004
- 云南互联网协会理事单位
- 安全联盟认证网站身份V标记
- 域名注册服务机构许可:滇D3-20230001
- 代理域名注册服务机构:新网数码
MySQL报错Can not connect to MySQL server. Too many connections,报错很明确,与MySQL的连接数满了。mysql最大连接数默认为100,看来有必要改大一点了。
方法:修改配置,然后重启
vi /etc/m.cnf加入max_connections=1024,然后重启mysql即可。
需要注意的是有时候重启后max_connections变成了214,这就很诡异了。
查阅了官方文档:
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.
把上述语句概括起来就是,max_connections依托于操作系统,Linux系统必要时需要增加open-files-limit。万万没想到啊,修改max_connections竟然要修改操作系统最大文件描述符。
vi /usr/lib/systemd/system/mysqld.service加入
LimitNOFILE=50000
重启MySQL
售前咨询
售后咨询
备案咨询
二维码
TOP