MySQL - How to get the database size in MySQL?
From query editor, run this query:
SELECT
table_schema AS 'DB Name',
ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) AS 'DB Size in MB'
FROM
information_schema.tables
GROUP BY
table_schema;
It will return the size of each database from the current connection.
If you want to get the size of only one database instead of the entire connection, insert WHERE
into the statement:
SELECT
table_schema AS 'DB Name',
ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) AS 'DB Size in MB'
FROM
information_schema.tables
WHERE
table_schema = 'db_name'
GROUP BY
table_schema;
Need a good GUI Tool for MySQL? TablePlus is a modern, native tool with an elegant UI that allows you to simultaneously manage multiple databases such as MySQL, PostgreSQL, SQLite, Microsoft SQL Server and more.