chenchen
chenchen

Reputation: 49

What's the command to get Mysql's total disk space?

Tried to do some researching and always ends up with

select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data 
    FROM TABLES WHERE table_schema='home';

which shows the total size that has already been used, is there any command that I can use to see the total disk space(capacity of the server)?

Upvotes: 1

Views: 9162

Answers (2)

Schwern
Schwern

Reputation: 165110

The total disk space available to MySQL is the total space remaining on that disk partition. You can check that with the df command. The MySQL database is often in /var/lib/db but you'll have to check your configuration to be sure.

If you're on a hosted server, you might also have a disk quota. How to check that depends on your hosting service.

Upvotes: 2

jay
jay

Reputation: 146

This question has been answered [around four years ago][1].

To sum up the answer, run this command:

mysql> select table_schema, sum((data_length+index_length)/1024/1024) AS MB from information_schema.tables group by 1;
+--------------------+-----------------+
| table_schema       | MB              |
+--------------------+-----------------+
| prod               | 298025.72448921 |
| information_schema |      0.00781248 |
| maatkit            |     70.77330779 |
| mysql              |      0.66873168 |
| test               |   4752.31449127 |
+--------------------+-----------------+
5 rows in set (0.01 sec)

If you have a very large number of tables, it can be slow, as you have already discovered.

Hope this is helpful.

Upvotes: 10

Related Questions