首页  

mysql连接信息查看     所属分类 mysql 浏览量 1431
show status like 'Threads%';

 Threads_cached    | 58     
 Threads_connected | 57       
 Threads_created   | 3676  
 Threads_running   | 4    

Threads_connected 打开的连接数

Threads_connected 跟show processlist结果相同,表示当前连接数。



show variables like '%max_connections%';
数据库当前设置的最大连接数
max_connections 1000


显示当前连接信息
show processlist;

Id  User    Host    db  Command Time    State   Info

719 dyyx dyyx001:46538 mydb Sleep 37 null

2226 dyyx 10.57.240.25:53166 mydb Query 0 starting show processlist
2496 dyyx 10.57.240.25:62080 mydb Query 0 executing  select * from  information_schema.processlist

show processlist  前100条
show full processlist   所有




查看每个ip的连接数

select SUBSTRING_INDEX(host,':',1) as ip , count(*) from information_schema.processlist group by ip

查看每个数据库的连接数
select db , count(*) from information_schema.processlist group by db

活跃连接数
Select * from information_schema.processlist where command!='sleep'

information_schema.processlist 表结构 

ID   bigint(21) unsigned
USER varchar(32)
HOST varchar(64)
DB      varchar(64)
COMMAND varchar(16)
TIME   int(7)
STATE  varchar(64)
INFO  longtext



显示连接状态
SHOW STATUS LIKE '%connect%';


Variable_name	Value
Aborted_connects 17
Connection_errors_accept 0
Connection_errors_internal 0
Connection_errors_max_connections 0
Connection_errors_peer_address 0
Connection_errors_select 0
Connection_errors_tcpwrap 0
Connections 2226
Locked_connects 0
Max_used_connections 46
Max_used_connections_time 2019-10-08 18:18:25
Performance_schema_session_connect_attrs_lost 0
Ssl_client_connects 0
Ssl_connect_renegotiates 0
Ssl_finished_connects 0
Threads_connected 20

上一篇     下一篇
metaspace OOM 实例

规则引擎easyrules

Mysql锁机制

Java锁机制

java资源加载方式比较

java number 比较陷阱