#查看線程數,連接數
show status like 'Threads%';
show STATUS LIKE '%Connection%';
#最大連接數
show VARIABLES LIKE '%max_connections%';
#當前線程狀態
show PROCESSLIST;
show FULL PROCESSLIST;
查看my.cnf目錄
查看mysql默認讀取my.cnf的目錄
mysql --help|grep 'my.cnf'
鎖解表
FLUSH TABLES WITH READ LOCK
unlock tables
查看引擎
show engines
查看mysql數據庫大小、表大小、數據大小、索引大小
select sum(DATA_LENGTH) from information_schema.TABLES where information_schema.TABLES.TABLE_SCHEMA='database' and information_schema.TABLES.TABLE_NAME='table'
表結構
select TABLE_SCHEMA,TABLE_NAME,COLUMN_NAME,COLUMN_TYPE,COLUMN_COMMENT from information_schema.columns where TABLE_SCHEMA='table'
查看數據庫、表大小
select concat(round(sum(data_length/1024/1024),2),'MB') as data_length_MB,concat(round(sum(index_length/1024/1024),2),'MB') as index_length_MB from tables where table_schema='庫名' and table_name = '表名';
查看實例下所有庫大小
select table_schema, sum(data_length+index_length)/1024/1024 as total_mb, sum(data_length)/1024/1024 as data_mb, sum(index_length)/1024/1024 as index_mb,count(*) as tables, curdate() as today from information_schema.tables group by table_schema order by 2 desc;
查看某個庫中的所有表佔用並按表大小倒敘
select table_name, (data_length/1024/1024) as data_mb , (index_length/1024/1024) as index_mb,((data_length+index_length)/1024/1024) as all_mb, table_rows from information_schema.tables where table_schema = 'bmdb' GROUP BY data_mb desc;