Beta 42

Research and Development

Menu

Check the Size of MySQL Databases

Run the following script in MySQL prompt.

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

The output should be similar to this:

+--------------------+-------------+
| Database           | Size (MB)   |
+--------------------+-------------+
| information_schema |  0.15625000 |
| mysql              |  2.51440334 |
| performance_schema |  0.00000000 |
| somedb1            |  0.00596619 |
| somedb2            |  6.40767288 |
| somedb3            | 26.02856350 |
| somedb4            | 22.16141224 |
| somedb5            |  5.23492241 |
| sys                |  0.01562500 |
+--------------------+-------------+
9 rows in set (0.04 sec)

Should you need sizes in GB, you can add an additional / 1024 before AS "Size (MB)" above.