Linux下查看MySQL占用磁盘空间大小
Posted 看,未来
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux下查看MySQL占用磁盘空间大小相关的知识,希望对你有一定的参考价值。
1、进入mysql数据库
2、查看所有库:
select TABLE_SCHEMA,
concat(truncate(sum(data_length)/1024/1024,2),' MB') as data_size,
concat(truncate(sum(index_length)/1024/1024,2),'MB') as index_size
from information_schema.tables group by TABLE_SCHEMA order by data_length desc;
3、查看单个库
select concat(truncate(sum(data_length)/1024/1024,2),'MB') as data_size,
concat(truncate(sum(max_data_length)/1024/1024,2),'MB') as max_data_size,
concat(truncate(sum(data_free)/1024/1024,2),'MB') as data_free,
concat(truncate(sum(index_length)/1024/1024,2),'MB') as index_size
from information_schema.tables where TABLE_SCHEMA ='databasename';
4、查看单库下所有表
select TABLE_NAME, concat(truncate(data_length/1024/1024,2),' MB')as data_size,
concat(truncate(index_length/1024/1024,2),' MB') as index_size
from information_schema.tables where
TABLE_SCHEMA = 'databasename' group by TABLE_NAME order by data_length desc;
5、查看单库下单表
SELECT TABLE_NAME,DATA_LENGTH+INDEX_LENGTH,TABLE_ROWS FROM TABLES
WHERE TABLE_SCHEMA='数据库名' AND TABLE_NAME='表名'
以上是关于Linux下查看MySQL占用磁盘空间大小的主要内容,如果未能解决你的问题,请参考以下文章
linux如何查看系统占用磁盘空间最大的文件及让文件按大小排序