Finding MySQL Database Size

Here’s the SQL script to list out the entire databases size.

SELECT table_schema "Data Base Name",
SUM( data_length + index_length) / 1024 / 1024 "Data Base Size in MB"
FROM information_schema.TABLES
GROUP BY table_schema;
SELECT TABLE_NAME, table_rows, data_length, index_length,
round(((data_length + index_length) / 1024 / 1024),2) "Size in MB"
FROM information_schema.TABLES
WHERE table_schema = "schema_name";

Following is the calculation:

data_length + index_length = total table size.

data_length = store the real data.
index_length = store the table index.

Leave a Reply