Friday, December 24, 2021

script to check database size in MySQL?

script to  check database size in MySQL


SELECT table_schema AS 'Database Name',  

SUM(data_length + index_length) 'Size in Bytes',  

ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) 'Size in MB'  

FROM information_schema.tables  

WHERE table_schema = 'mysql'  

GROUP BY table_schema;  

+---------------+---------------+------------+

| Database Name | Size in Bytes | Size in MB |

+---------------+---------------+------------+

| mysql         |       5292032 |       5.05 |

+---------------+---------------+------------+

1 row in set (0.00 sec)


No comments:

Post a Comment