How big is my MySQL database?
mysql> SELECT table_schema,
sum(data_length) / 1024 / 1024 "data",
sum(index_length) / 1024 / 1024 "index",
sum( data_length + index_length ) / 1024 / 1024 "total"
FROM information_schema.TABLES
GROUP BY table_schema \G;
*************************** 1. row ***************************
table_schema: aardvarks_development
data: 5297.32812500
index: 4407.93750000
total: 9705.26562500
*************************** 2. row ***************************
table_schema: aardvarks_test
data: 0.09375000
index: 0.25000000
total: 0.34375000
*************************** 3. row ***************************
table_schema: badgers_development
data: 13.59375000
index: 16.60937500
total: 30.2031250
as you can see, aardvarks_developpment is almost taking up 10gig
if we only care about “test” databases, we can add a condition on “table_schema”
mysql> SELECT table_schema,
sum(data_length) / 1024 / 1024 "data",
sum(index_length) / 1024 / 1024 "index",
sum( data_length + index_length ) / 1024 / 1024 "total"
FROM information_schema.TABLES
WHERE table_schema like "%_test"
GROUP BY table_schema \G;
*************************** 1. row ***************************
table_schema: aardvarks_test
data: 0.09375000
index: 0.25000000
total: 0.3437500
Boom!
(credit to Paul Butcher for the query)