压测的时候,遇到了一个数据库报错:
Can not connect to MySQL server. Too many connections
原因是压测的时候,数据库的链接数超过最大
查看Mysql的最大连接数
show variables like '%max_connections%';
临时设置最大连接数(重启失效)
set GLOBAL max_connections=1000;
修改mysql配置,重启后生效
找到mysql的my.cnf文件,增加配置max_connections=100
[mysqld]
character-set-server=utf8
explicit_defaults_for_timestamp=true
max_allowed_packet=256M
max_connections=4532