<?php
$host ="localhost"; // 호스트를 식별할 수 있는 호스트명이나 ip
$user =""; //MySQL에서 사용할 데이터베이스 사용자명
$password = ""; // MySQL에서 사용할 데이터베이스에 접속하기 비밀번호
$database = ""; // MySQL에서 사용할 데이타베이스명
// 데이터베이스 연결
$conn = mysql_connect ($hostname, $user, $password) or die(mysql_error());
mysql_select_db($database,$conn) or die(mysql_error());
$result = mysql_query("SHOW TABLE STATUS", $conn);
$total = 0;
$i = 1;
while($row=mysql_fetch_array($result)){
$total += $row[Data_length]+$row[Index_length];
$i++;
}
// 데이터베이스 연결 끊기
mysql_close($conn);
// MySQL 데이터베이스 사용량 출력
printf("%0.2f MB",$total / (1024*1024));
?>