How to get size of mysql database?

0 votes
asked Nov 14, 2009 by newbie

How to get size of a mysql database?
Suppose the target database is called "v3".

3 Answers

0 votes
answered Nov 14, 2009 by brian-willis

Run this query and you'll probably get what you're looking for:

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; 

This query comes from the mysql forums, where there are more comprehensive instructions available.

0 votes
answered Jan 29, 2013 by joel

Alternatively, if you are using phpMyAdmin, you can take a look at the sum of the table sizes in the footer of your database structure tab. The actual database size may be slightly over this size, however it appears to be consistent with the table_schema method mentioned above.

Screen-shot :

enter image description here

0 votes
answered Sep 15, 2017 by williambarau

To get a result in MB:

SELECT  SUM(ROUND(((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024 ), 2)) AS "SIZE IN MB"
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = "SCHEMA-NAME";`

To get a result in GB:

SELECT  SUM(ROUND(((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024 /1024 ), 2))  AS "SIZE IN GB"
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = "SCHEMA-NAME";`
Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter

...