How to Calculate and List Sizes of MySQL / MariaDB Databases

Question :
I am finding the best way to calculate and list sizes of MySQL or MariaDB Databases ?

Answer :

In order to achive this, please do the following.

1. Enter to mysql root console:

# mysql -u root -p

2. Run the following SQL select query to calculate and list the sizes of all available databases in MySQL or MariaDB.

MariaDB [(none)]> SELECT table_schema AS "DB Name", SUM(data_length + index_length) / 1024 / 1024 AS "Size (MB)" FROM information_schema.TABLES GROUP BY table_schema;

Output :

| DB Name            | Size (MB)   |
| wordpressdb        | 36.79408455 |
| information_schema |  0.14062500 |
| mysql              |  0.62723351 |
| oscommercedb       |  1.42187500 |
| performance_schema |  0.00000000 |
5 rows in set (0.02 sec)

MariaDB [(none)]>


Leave a Reply

Your email address will not be published. Required fields are marked *

A world leading hosting company that provides fully-managed innovative and secure solutions, suitable for hosting small to medium-sized websites

Built on the best available technologies combined with Google Cloud for strong redundancy and application availability. Backed by skilled experts to address web security threats, a devops team to create advanced custom security solutions, and 24/7 sysadmins to watch over the platform. This powerful, hands-on approach makes your sites faster, safer, and easier to manage. Starting from only $3.95/mo.


* up to 30 days money back guarantee