#查看线程数,连接数
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;