Page 1 of 1

MySQL database size?

Posted: Tue Dec 28, 2004 7:06 pm
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']);

Posted: Tue Dec 28, 2004 9:34 pm
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