no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | tech:mysql:check_all_database_sizes [2014/11/15 15:13] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Check the size of all MySQL databases ====== | ||
+ | The script below will get the sizes of all databases for a MySQL server. Make sure you " | ||
+ | <code sql> | ||
+ | CREATE TABLE z_db_size | ||
+ | SELECT TABLE_SCHEMA AS ' | ||
+ | ((DATA_LENGTH + INDEX_LENGTH - DATA_FREE) / 1024 / 1024) AS size_in_mb | ||
+ | FROM INFORMATION_SCHEMA.TABLES; | ||
+ | </ | ||
+ | |||
+ | Will create temporary table z_db_size | ||
+ | |||
+ | <code sql> | ||
+ | select database_name, | ||
+ | from z_db_size | ||
+ | group by database_name | ||
+ | order by sum(size_in_mb); | ||
+ | </ | ||
+ | |||
+ | Once report is captured, drop temporary table | ||
+ | <code sql> | ||
+ | drop table z_db_size; | ||
+ | </ | ||