首先还是看一下防火墙等是不是阻断.
我遇到了之后,查了很多资料都说是防火墙问题,其实并不是,而是数据库的最大连接数满了.默认的是256.
1.vim /etc/my.cnf
[mysqld]
max_connections=需要添加的最大连接数
2.vim /etc/systemd/system.conf
DefaultLimitNOFILE=65535
DefaultLimitNPROC=65535
3.重启
systemctl daemon-reload
systemctl restart mysqld.service
- 查看最大连接数
mysql>show variables like ‘max_connections’;
查看当前连接数
show status like ‘%thread%’;
搞定!!