MySQL

Calculate MySQL Database size

Today we will see how we can retrieve MySQL database size.

All databases:

SELECT table_schema "Database", SUM( data_length + index_length) / 1024 / 1024 
"size in MB" FROM information_schema.TABLES GROUP BY table_schema ;

Specific database:

SELECT table_schema "Database", SUM( data_length + index_length) / 1024 / 1024 
"size in MB" FROM information_schema.TABLES WHERE table_schema='information_schema';