MySQL : How to Check MySQL database and table size



MySQL : How to Check MySQL database and table size

MySQL : How to Check MySQL database and table size

MySQL : How to Check MySQL Database Size

To check the size of MySQL databases use the database called information_schema which provides access to database metadata,
including the size of the databases and tables.

mysql -u root -p
Mysql@1234

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

To determine the sizes of all of the tables in a specific database
******************************************************************
Replace database_name with the name of the database that you want to check.

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