[KLUG Members] Fw: [linux-Ahmedabad-users] How to get size of
Database in MySQL
bill
members@kalamazoolinux.org
Tue, 10 Feb 2004 11:01:12 -0500
Or, you could use some PHP if you have it running:
<?
/*
Function that returns whole size of a given MySQL database
Returns false if no db by that name is found
*/
function getdbsize($tdb) {
$db_host='localhost';
$db_usr='USER';
$db_pwd='XXXXXXXX';
$db = mysql_connect($db_host, $db_usr, $db_pwd) or die ("Error
connecting to MySQL Server!\n");
mysql_select_db($tdb, $db);
$sql_result = "SHOW TABLE STATUS FROM " .$tdb;
$result = mysql_query($sql_result);
mysql_close($db);
if($result) {
$size = 0;
while ($data = mysql_fetch_array($result)) {
$size = $size + $data["Data_length"] + $data["Index_length"];
}
return $size;
}
else {
return FALSE;
}
}
?>
<?
/*
Implementation example
*/
$tmp = getdbsize("DATABASE_NAME");
if (!$tmp) { echo "ERROR!"; }
else { echo $tmp; }
?>
http://www.php.net/manual/en/function.mysql-list-tables.php
Richard Harding wrote:
> if you use phpmyadmin for the server you can go to database statistics
> from the main menu and it shows the total size of all databases.
>
> Rick
>
> komal wrote:
>
>> ----- Original Message -----
>> From: Jigar Vakharia
>> To: linux-Ahmedabad-users@yahoogroups.com
>> Sent: Tuesday, February 10, 2004 4:04 PM
>> Subject: [linux-Ahmedabad-users] How to get size of Database in MySQL
>>
>>
>>
>> Hi,
>>
>> i am having space constrains on my database server, and need to plan
>> for one
>> new project, so i need to calculate the space available on my current
>> database server, so please can any one tell me how to get the space
>> available and also how to calculate space used by different databases
>> already existing.
>>
>> i am using one full machine (i.e. a full system of 20 GB) for my MySQL
>> server, nothing else is there on that PC other than database, and its on
>> linux.
>>
>> thanks for your help in advance.
>>
>> jigaruu....
>>
>>
>>
>>
>>
>> Do you Yahoo!?
>> Yahoo! Finance: Get your refund fast by filing online
>>
>> To unsubscribe, email to:
>> linux-Ahmedabad-users-unsubscribe@yahoogroups.com
>>
>>
>>
>> Yahoo! Groups Sponsor
>> ADVERTISEMENT
>>
>>
>>
>>
>>
>>
>> Yahoo! Groups Links
>>
>> To visit your group on the web, go to:
>> http://groups.yahoo.com/group/linux-Ahmedabad-users/
>>
>> To unsubscribe from this group, send an email to:
>> linux-Ahmedabad-users-unsubscribe@yahoogroups.com
>>
>> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>>
>> _______________________________________________
>> Members mailing list
>> Members@kalamazoolinux.org
>>
>
> _______________________________________________
> Members mailing list
> Members@kalamazoolinux.org
>
>
>
>