Notes

Find out MySQL Database sizes

Edit on GitHub


Databases
1-- DB size in GB
2SELECT TABLE_SCHEMA "DB Name", ROUND(SUM(DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024 / 1024, 2) "DB Size in GB" FROM INFORMATION_SCHEMA.TABLES GROUP BY TABLE_SCHEMA;
3
4-- DB size in MB
5SELECT TABLE_SCHEMA "DB Name", ROUND(SUM(data_length + INDEX_LENGTH) / 1024 / 1024, 2) "DB Size in MB" FROM INFORMATION_SCHEMA.TABLES GROUP BY TABLE_SCHEMA; 
+--------------------+---------------+
| test               | DB Size in GB |
+--------------------+---------------+
| foo                |         36.56 |
| bar                |         20.62 |
| information_schema |          0.00 |
| mysql              |          0.00 |
| performance_schema |          0.00 |
+--------------------+---------------+
5 rows in set (56.61 sec)

Related