How to calculate the size of a database in MySQL

To display a breakdown of the sizes of all the tables in your database:

SELECT
  table_schema AS `Database`,
  table_name AS `Table`,
  ROUND((data_length + index_length) / 1024 / 1024, 2) `Size in MB`
FROM 
  information_schema.TABLES
ORDER BY 
  (data_length + index_length) DESC;

If you’d just like to see the total, simply use a SUM() function like this:

SELECT
  SUM(ROUND((data_length + index_length) / 1024 / 1024, 2)) `Size in MB`
FROM 
  information_schema.TABLES