Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: mySQL command to print the Database Size.  (Read 5520 times)

0 Members and 1 Guest are viewing this topic.

sajay

  • Guest
mySQL command to print the Database Size.
« on: November 06, 2013, 11:10:01 pm »

 Using this mySQL query we can view the size of Databases :

 1.Login to the server
 2.Enter in to the mySQL prompt

Execute the following command

  mysql> SELECT table_schema "DB Name", Round(Sum(data_length + index_length)  / 1024, 2) "DB Size in KB"  FROM   information_schema.tables  GROUP  BY table_schema;

+--------------------+---------------+
| DB Name            | DB Size in KB |
+--------------------+---------------+
| information_schema  |          8.00 |
| joomla                       |       3808.00 |
| mysql                        |        655.79 |
| sched                        |          8.02 |
| shift                          |         44.18 |
| wp                            |        439.70 |
+--------------------+---------------+
6 rows in set (0.02 sec)

If you want to print the Database size in MB

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 |
+--------------------+---------------+
| information_schema |   0.0 |
| joomla              |           3.7        |
| mysql                |           0.6        |
| sched               |           0.0         |
| shift                 |            0.0         |
| wp                   |            0.4         |
+--------------------+---------------+
6 rows in set (0.02 sec)