Search code examples
mysqldatabasesize

How can I know the database size of specific database in MYSQL?


I have a database named 'phonebook'. It contains 10+ tables with a moderate amount of data.
Now I want to know the database size of this 'phonebook' database using MySQL query.
How can I do that?


Solution

  • Try this, it provides the size of a specified database in MBs.

    Make sure you specify DB_NAME

        SELECT table_schema,
        ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB" 
        FROM information_schema.tables  WHERE table_schema='DB_NAME'
        GROUP BY table_schema ;  
    

    Hope this will help you ! .