数据库连接相关命令
1.查看数据库最大连接数
show variables like ‘%max_connections%’;
2.查看当前数据库使用连接数,Threads_connected显示的数值就是当前的连接数
SHOW STATUS LIKE ‘Threads%’;
3.查看当前各用户连接数据库的数量
select USER , count(*) from information_schema.processlist group by USER;
4.查看连接到数据库的客户端ip及各连接数
SELECT substring_index(host, ‘:’,1) AS host_name,state,count(*) FROM information_schema.processlist GROUP BY state,host_name;
5.查看连接到数据库的账号、客户端ip及各连接数
SELECT user,substring_index(host, ‘:’,1) AS host_name,state,count(*) FROM information_schema.processlist GROUP BY state,host_name;
6.如果要修改最大连接数为500
set global max_connections=500;
也可以修改mysql配置文件max_connections=500,然后重启mysql生效