How to get the size of the MySQL database using PHP script?

Posted on February 11, 2020
PHP
SELECT table_schema "Databases",
        ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB" 
FROM information_schema.tables 
GROUP BY table_schema; 

Run this query and you'll probably get what you're looking for.