「MySQL」- 获取MySQL中库的大小

  CREATED BY JENKINSBOT

问题描述

在MySQL中,如何获取特定数据库(或特定表)所占用的磁盘空间的大小?

解决办法

在通常情况下,数据表与数据索引会占用磁盘空间(其他部分可以忽略):

SELECT table_schema AS "DB Name",
        ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) AS "DB Size in MB"
FROM information_schema.tables
GROUP BY table_schema;

参考文献

How to get size of mysql database?