how to check the size of the individual database in MySQL or MariaDB1 min read

We need your support!!
Other Amount:
techrunnr.com:
24-Hour Flash Sale. Courses from just ₹ 490.
Prabhin Prabharkaran Administrator
DevOps Engineer

He is a Technical professional. He is a person who loves to share tricks and tips on the Internet. He Posts what he does!

follow me

Hi all, this document deals with how to check the size of the individual database in MySQL or MariaDB.
Sometimes as a database administrator it’s required to check the size of the individual databases in database servers. So here is the command to check the sizes.


Step 1: log in to Database server ( Mysql/MariaDB)

mysql -u root -p

Step 2: Execute the following command to get the individual size of all the schemas.

In GB

SELECT table_schema AS "Database", SUM(data_length + index_length) / 1024 / 1024 / 1024 AS "Size (GB)" FROM information_schema.TABLES GROUP BY table_schema

IN MB

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;

Here is the command to see the Size of the table.

 

SELECT 
table_name AS `Table`, 
ROUND(((data_length + index_length) / 1024 / 1024/1024), 2) `Size in GB` 
FROM information_schema.TABLES 
WHERE table_schema = "<SCHEMA_NAME>";

We need your support!!
Other Amount:
techrunnr.com:
#1
#2
#3
Questions Answered
Articles Written
Overall Points

Prabhin Prabharkaran

He is Technical professional. He is a person who loves to share tricks and tips on the Internet. He Posts what he does!!

You may also like...

Leave a Reply