Database size of a MySQL server instance

How to obtain the database size of a MySQL Server instance?

Database query

With this query you can obtain the size of the data, indexes and total for each database.

select
table_schema DBNAME,
sum(data_length)/1024/1024 TABLESMB,
sum(index_length)/1024/1024 INDEXESMB,
sum( data_length + index_length )/1024/1024 TOTALMB
FROM information_schema.TABLES
group by table_schema
order by TOTALMB DESC;

The results are expressed in Megabytes (MB).

Leave a Reply

Your email address will not be published. Required fields are marked *