As part of administering our customer MySQL databases we often want to know the size of databases, tables and indexes. These are a few of the commands we commonly use on MySQL and Percona 5.6. We have shown example output from real databases, but have changed database and table names to protect the innocent.
Database Sizes
If you want to know the size of all databases in gigabytes (GiB):
If you want to know the size of all databases in megabytes (MiB):
Tables and Index Sizes
The following command finds the size of data and indexes for all tables in the current database. The ordering is by the total size of the data and index: you can adjust the ORDER BY clause to sort by data or index length instead. This command can easily be adjusted to work for a named database by changing WHERE table_schema =.
Total Rows in Database
If you want a quick estimate of the number of rows in each database you can grab the information from the information_schema:
NB. This is fast but isn’t exact; it’s the row count used by the optimiser.