MySQL: size of each database
List the size of each MySQL database in MB, from information_schema.
The following query lists the size of each database on a MySQL or MariaDB server. The size is the sum of the data and index lengths of the tables stored in information_schema, in MB rounded to one decimal.
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;
Notes
- The values come from table metadata and are estimates, not an exact measure of the space used on disk.
- Binary logs, error logs and other files outside the tables are not included.