Posted over 7 years ago. Visible to the public. Linked content.

List sizes of MySQL databases

Do you wonder which databases are actually taking up how much space but only have one huge ibdata1 in your /var/lib/mysql and the directories inside your mysql data directory don't represent the actual database sizes? This is for you!

Run from a mysql root console:

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

This will get you a result like the following:

Copy
+----------------------+--------------+ | Database name | Size (MB) | +----------------------+--------------+ | information_schema | 0.00781250 | | mysql | 0.61204815 | | project1_development | 281.59375000 | | project1_test | 7.29687500 | | project2_development | 2.65625000 | | project2_test | 0.15625000 | +----------------------+--------------+

Once an application no longer requires constant development, it needs periodic maintenance for stable and secure operation. makandra offers monthly maintenance contracts that let you focus on your business while we make sure the lights stay on.

Owner of this card:

Avatar
Arne Hartherz
Last edit:
over 4 years ago
by Arne Hartherz
Keywords:
show, calculate, space, consumption
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Arne Hartherz to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more