脚本如下:
//查看 最大连接数
show variables like "max_connections";
//设置 最大连接数
set global max_connections = 10000;
//查看 允许连接失败的最大尝试次数, 某主机(host)连接本数据库,失败次数超过max_connect_errors时,会报错:Host X is blocked because of many connection errors;
show variables like "max_connect_errors";
//设置 允许连接失败的最大尝试次数
set global max_connect_errors=100;
//当连接失败次数超过max_connect_errors,导致某IP被锁定时,使用flush host解锁:
flush hosts;
//查看 当前实际连接数
SHOW STATUS LIKE 'Threads_connected';
//查看 当前具体有哪些连接,输出对应的主机IP
SELECT substring_index(host, ':',1) AS host_name,state,count(*) FROM information_schema.processlist GROUP BY state,host_name;