Hi Techrunnr Readers, this document deals with how to check database size in mysql.
MySQL is an open-source relational database management system. Its name is a combination of “My”, the name of co-founder Michael Widenius’s daughter, and “SQL”, the abbreviation for Structured Query Language.

It’s very biggest headache for database administrators/sysadmin to check the database size. Here is the solution for that. Perform the following steps to get size if of databases in Mysql or MariaDB.

1. Login to mysql

mysql -u root -p

2. Execure the following query to get the size.

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 expected output for the above query.


mysql> 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; 
+--------------------+---------------+
| DB Name            | DB Size in MB |
+--------------------+---------------+
| news               |           0.8 |
| information_schema |           0.2 |
| mysql              |           2.5 |
| performance_schema |           0.0 |
| techrunnr          |          10.8 |
| sys                |           0.0 |
+--------------------+---------------+
6 rows in set (0.22 sec)

You can alter the above query to get size in GB etc.

Have good learning

© 2018, Techrunnr. All rights reserved.

#1
#2
#3
Questions Answered
Articles Written
Overall Points
Categories: database

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!!

Leave a Reply

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.