1.找到mysql的配置文件 mysql.cnf , 我的路径是 /etc/mysql/mysql.conf.d/mysqld.cnf
2 编辑配置文件 找到 max_connections(最大连接数) 并更改数值,添加 wait_timeout(超时时间)
vim /etc/mysql/mysql.conf.d/mysqld.cnf
3. 然后在重启服务即可
service mysql restart
以下方法 服务重启失效 需要重新设置
查看最大连接数
show variables like '%max_connections%';
设置最大连接数
set GLOBAL max_connections=300;
查看超时间
show global variables like 'wait_timeout';
设置超时时间
set global wait_timeout=30;
查看连接数
show processlist;