EN
MySQL - how to check database size?
17
points
Using MySQL querry it is possible to check database size in following way.
1. Size in bytes query example
SELECT
`table_schema` AS 'database_name',
SUM(data_length + index_length) AS 'database_size'
FROM `information_schema`.`tables `
GROUP BY `table_schema`;
Result:
2. Size in kilobytes query example
SELECT
`table_schema` AS 'database_name',
ROUND(SUM(data_length + index_length) / 1024, 2) AS 'database_size'
FROM `information_schema`.`tables`
GROUP BY `table_schema`;
Result:
3. Size in megabytes query example
SELECT
`table_schema` AS 'database_name',
ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS 'database_size'
FROM `information_schema`.`tables`
GROUP BY `table_schema`;
Result: