![mysql 数据库磁盘占用量统计 mysql 数据库磁盘占用量统计](https://image.shishitao.com:8440/aHR0cHM6Ly9ia3FzaW1nLmlrYWZhbi5jb20vdXBsb2FkL2NoYXRncHQtcy5wbmc%2FIQ%3D%3D.png?!?w=700&webp=1)
查看某个表的磁盘占用量
select
(data_length+index_length)/1024/1024 M
from
information_schema.tables
where
table_schema="db_name" and table_name='table_name';
查看整个数据库的磁盘用量
select
sum((data_length+index_length)/1024/1024) M
from
information_schema.tables
where
table_schema="db_name" ;
查看整个mysql server 所有数据库的磁盘用量
select
table_schema, sum((data_length+index_length)/1024/1024) M
from
information_schema.tables
where
table_schema is not null
group by
table_schema ;