Hello,
Any one know how to get database size by php
I find that but not worked for me:
and thatPHP Code:<?php
$sql = "SHOW TABLE STATUS";
$result = mysql_query($sql); // This is the result of executing the query
while($row = mysql_fetch_array($result))// Here we are to add the columns 'Index_length' and 'Data_length' of each row
{
$total = $row['Data_length']+$row['Index_length'];
}
echo($total); // here we print the file size in bytes
?>
Any one have other methods?PHP Code:function getDbSize($dbname){
$size=shell_exec("du -b /var/lib/mysql/$dbname");
$size=explode(' ',$size);
return $size[0];
}
Thanks





Bookmarks