mysqldatabase

How can I get the size of a MySQL database?


How can I get the size of a MySQL database?

Suppose the target database is called "v3".


Solution

  • 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.