Calculate size of databases from information schema

I was working on a project where i need to work with database, suddenly a query raise in my mind , that is database size… yes How to calculate databases size with a single query. So I get to know and sharing this to you also

Mysql 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

Copy above query and paste in Sql tab of local mysql software like Xampp or Wampp. This will results with two columns named “DB Name” and “DB Size in MB”.

Screenshot:

mysql_databases