Skip to content

Instantly share code, notes, and snippets.

@anytizer
Created February 20, 2014 06:32
Show Gist options
  • Save anytizer/9108138 to your computer and use it in GitHub Desktop.
Save anytizer/9108138 to your computer and use it in GitHub Desktop.
How to get size of mysql database?
-- http://forums.mysql.com/read.php?108,201578,201578
SELECT
table_schema "Data Base Name",
SUM( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB",
SUM( data_free )/ 1024 / 1024 "Free Space in MB"
FROM information_schema.TABLES
GROUP BY table_schema;
SELECT table_schema "Data Base Name", SUM( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB"
FROM information_schema.TABLES GROUP BY table_schema ;
-- http://stackoverflow.com/questions/1733507/how-to-get-size-of-mysql-database
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
ORDER BY `DB Size in MB` DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment