Read more

List sizes of MySQL databases

Arne Hartherz
August 10, 2011Software engineer at makandra GmbH

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!

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

Run from a mysql root console:

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:

+----------------------+--------------+
| 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 |
+----------------------+--------------+
Posted by Arne Hartherz to makandra dev (2011-08-10 15:54)