Find MySQL Database and Table Size

To find the size of databases using SQL command, run the following SQL in MySQL prompt.

SELECT table_schema AS "Database", ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "Size (MB)" FROM information_schema.TABLES GROUP BY table_schema;

Example

MySQL database disk usage

FInd disk usage by tables

To find disk usage by tables in database, run

Advertisement

SELECT table_name AS "Table", round(((data_length + index_length) / 1024 / 1024), 2) as "size (MB)" FROM information_schema.TABLES WHERE table_schema = "DB_NAME_HERE"  ORDER BY data_length DESC;

In the above SQL, replace DB_NAME_HERE with the actual name of the database.

Example

SELECT table_name AS "Table", round(((data_length + index_length) / 1024 / 1024), 2) as "size (MB)" FROM information_schema.TABLES WHERE table_schema = "xogifts_db"  ORDER BY data_length DESC;
MySQL table disk usage
Add a comment

Leave a Reply

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

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Advertisement