How to Get True Size of MySQL Database? How to Get True Size of MySQL Database? mysql mysql

How to Get True Size of MySQL Database?


From S. Prakash, found at the MySQL forum:

SELECT table_schema "database name",    sum( data_length + index_length ) / 1024 / 1024 "database size in MB",    sum( data_free )/ 1024 / 1024 "free space in MB"FROM information_schema.TABLESGROUP BY table_schema; 

Or in a single line for easier copy-pasting:

SELECT table_schema "database name", sum( data_length + index_length ) / 1024 / 1024 "database size in MB", sum( data_free )/ 1024 / 1024 "free space in MB" FROM information_schema.TABLES GROUP BY table_schema; 


You can get the size of your Mysql database by running the following command in Mysql client

SELECT  sum(round(((data_length + index_length) / 1024 / 1024 / 1024), 2))  as "Size in GB"FROM information_schema.TABLESWHERE table_schema = "<database_name>"


If you use phpMyAdmin, it can tell you this information.

Just go to "Databases" (menu on top) and click "Enable Statistics".

You will see something like this:

phpMyAdmin screenshot

This will probably lose some accuracy as the sizes go up, but it should be accurate enough for your purposes.