Forum Moderators: coopster & phranque

Message Too Old, No Replies

MySQL Database Size

showing total size of db

         

wruk999

6:39 pm on Dec 7, 2002 (gmt 0)

10+ Year Member



hi all.

Just wondering if anyone can help:
I need a PHP script which will display the physical size of a database. ie: how many Mb's it is taking up?

Anyone with a script that can do this?

Regards,
Will

seindal

6:48 pm on Dec 7, 2002 (gmt 0)

10+ Year Member



Hi,

If you run the query "show table status" there is a column in the result called Data_length. This is the number of bytes of data in each table. Another column, Index_length, gives the same data for indexes on the table.

Sum them all up and you have your number.

René.

wruk999

6:55 pm on Dec 7, 2002 (gmt 0)

10+ Year Member



Hi seindal,

im a bit of a beginner to PHP (4 months) and dont know how to run the show table status

what would it involve, *just* to show the total size of the database?

Regards.

andreasfriedrich

7:12 pm on Dec 7, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could stat [php.net] the files in a database. But then you may not have permissions to do that. In fact if mysql is setup correctly then only root or the user mysqld runs as may even read the database files.

René´s approach is really the easiest one. Use mysql_query [php.net] to run the query and any of the mysql_fetch_* functions to retrieve the result.

Andreas