<?php // Mysql 사용량 출력 $host="localhost"; $user_name=""; $db_name=""; $db_password="";
// 데이터 베이스 접속 $dbcon = mysql_connect($host,$user_name,$db_password) or message(mysql_error()); mysql_select_db($db_name,$dbcon) or message(mysql_error());
// 전체 테이블 현황을 불러오는 쿼리문 $result = mysql_query("SHOW TABLE STATUS", $dbcon); $total_size = 0; $num = 1;
// 데이터베이스 크기구하는 반복문 while($dbData=mysql_fetch_array($result)){ $total_size += $dbData[Data_length]+$dbData[Index_length]; $num++; } // Mysql 사용량 출력 //////////////////////////////////////////////////////////////// // 닫기
mysql_close($dbcon); printf("%0.2f MB",$total_size / (1024*1024)); ?>
SQL
====================================================
SELECT table_schema "matjilyechan",
SUM(data_length + index_length) / 1024 / 1024 "Size(MB)"
FROM information_schema.TABLES
WHERE table_schema = 'matjilyechan'
GROUP BY table_schema;
'Developement > Web Programming' 카테고리의 다른 글
파일의 퍼미션을 보기 좋게 구하기 (0) | 2014.03.19 |
---|---|
계정 사용량 출력하기 (0) | 2014.03.19 |
정규식 문법 (0) | 2014.03.19 |
취약점 막기 (0) | 2014.03.05 |
웹사이트 최적화 방법론 (0) | 2014.03.03 |