MySQL Database size and free space

Every feel like your DB is getting a bit too big, but was unsure of the size. Well, this little MySQL Query will make you smile.

To check the size of your DB, run this query within MySQL:

MySQL Query to Show Database Size

SELECT table_schema "Data Base Name",
sum( data_length + index_length ) / 1024 / 1024 "Used MB"
FROM information_schema.TABLES
GROUP BY table_schema ;

So know you know that size of the db, but how much space do I have left on the DB?  We gotcha too! =)

MySQL Query to Show Database Size
SELECT table_schema "Data Base Name",
sum( data_length + index_length ) / 1024 / 1024 "Used MB",
sum( data_free ) / 1024 / 1024 "Free MB"
FROM information_schema.TABLES
GROUP BY table_schema ;