环境
centos7,mysql5.7
查看各个数据库大小
select
table_schema database_name,
sum(table_rows) row_s,
sum(truncate(data_length/1024/1024/1024, 2)) data_GB,
sum(truncate(index_length/1024/1024/1024, 2)) index_GB
from information_schema.tables
group by table_schema
order by sum(data_length) desc, sum(index_length) desc;
查看库中各个表大小
select
table_schema database_name,
table_name as table_name,
table_rows as row_s,
truncate(data_length/1024/1024, 2) data_MB,
truncate(index_length/1024/1024, 2) index_MB
from information_schema.tables
order by data_length desc, index_length desc;