How to get size of mysql database?

前端 未结 9 1982
栀梦
栀梦 2020-11-27 08:43

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

9条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-27 09:17

    First login to MySQL using

    mysql -u username -p

    Command to Display the size of a single Database along with its table in MB.

    SELECT table_name AS "Table",
    ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "Size (MB)"
    FROM information_schema.TABLES
    WHERE table_schema = "database_name"
    ORDER BY (data_length + index_length) DESC;
    

    Change database_name to your Database

    Command to Display all the Databases with its size in MB.

    SELECT table_schema AS "Database", 
    ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "Size (MB)" 
    FROM information_schema.TABLES 
    GROUP BY table_schema;
    

提交回复
热议问题