mysql性能監(jiān)控常用命令
1、查看正在執(zhí)行的sql
show processlist;
show full processlist;
2、查看死鎖
show engine innodb status
在輸出的
TRANSACTIONS部分,你可以找到正在進(jìn)行的事務(wù)列表,包括事務(wù)ID、狀態(tài)和鎖定情況。3、查找長(zhǎng)事務(wù)
SELECT trx_id, trx_state, trx_started, TIMEDIFF(NOW(), trx_started) AS duration FROM information_schema.innodb_trx WHERE TIMEDIFF(NOW(), trx_started) > '01:00:00'; -- 例如,查找持續(xù)時(shí)間超過(guò)1小時(shí)的事務(wù)
4、最大連接數(shù)
set GLOBAL max_connections=1000;
-- 當(dāng)前連接數(shù)
SHOW STATUS WHERE `variable_name` = 'Threads_connected';
-- 最大可能連接數(shù):
show variables like "%max_connection%"

浙公網(wǎng)安備 33010602011771號(hào)