Get The Size of MySQL Databases

I'm currently dealing with moving a client's web application over to a new host, and one of the hosts that the client wanted me to check out was 1&1.   The only problem with 1&1 that i could see was a 1GB limit on database size.

So i needed to check the size of the database right now, and normally, although not accurate, what i would normally do is do mysqldump of the db, and see how large that is.   On this occassion though i decided to research if there's a better and more accurate way of doing it.

I very quickly came accross running the following query :-

SELECT table_schema "DB Name",
Round(Sum(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB"
FROM   information_schema.tables
GROUP  BY table_schema;

This was found on StackOverflow.

Wednesday 03 July 2013 at 2:01 pm | ΒΆ | mysql | No comments