unrecognizable hacker with smartphone typing on laptop at desk
Photo by Sora Shimazaki on <a href="https://www.pexels.com/photo/unrecognizable-hacker-with-smartphone-typing-on-laptop-at-desk-5935791/" rel="nofollow">Pexels.com</a>

This article outlines the process of determining the size of a MySQL database and assessing the available free space within it.

Determine the database size:

Execute the following MySQL query to showcase the database name and its size in megabytes:

SELECT table_schema "DataBase", 
sum( data_length + index_length ) / 1024 / 1024 "DataBase Size in MB" 
FROM information_schema.TABLES 
GROUP BY table_schema ;

Determine the amount of available space:

Execute the subsequent query to observe the available free space in megabytes for a MySQL database.

SELECT table_schema "DataBase", 
sum( data_length + index_length ) / 1024 / 1024 "DataBase Size in MB",
sum( data_free )/ 1024 / 1024 "Free Space in MB"
FROM information_schema.TABLES
GROUP BY table_schema ;

Hope it worked !! 🙂