MySQL database size?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

MySQL database size?

Post by Joe »

Does anyone know how I can display how much space has been used in the mysql database?. I was thinking of using 'show table status' and then grabbing the Data_length entry but I am not sure how I should do it. When I try it only seems to be showing the size of the first table?.

Code: Select all

$sql = "SHOW TABLE STATUS FROM " . DATABASE_DBNAME;
$res = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($res);

define('SYS_MYSQL_DBSIZE', $row['Data_length']);
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

you mean something like:
http://www.webmasterworld.com/forum88/2069.htm ?

or you could make a system call and do something like
du -h /var/lib/mysql/databasename
Post Reply