PHP & Others

mysql Database 테이블 모두 최적화하기

페이지 정보

본문

php 버전 입니다.

<html>
<title>데이터 베이스 최적화</title>
<head>
<style>
td {
font-size : 9pt;
}
</style>
</head>

<body>
<center>

<table width="500" cellpadding="3" cellspacing="0" border="0" bgcolor="#efefef">
<tr>
<td align="center">

<table width="100%" cellpadding="2" cellspacing="0" style="border: 1px #cccccc solid" bgcolor="#ffffff">
<tr>
<td style="padding : 10 10 10;" align="center"><B>MySQL 최적화</B></td>
</tr>
</table>

</td>
</tr>
</table>

<br><br>

<?php

// 기본 설정
$host = "localhost";
$user = "root";
$pass = "pass";
$dbcon = mysql_connect($host, $user, $pass) or die(mysql_error());

// 디비 리스트
$que = "show databases";
$result = mysql_query($que, $dbcon) or die(mysql_error());

// 디비별로 최적화 실행
while($db = mysql_fetch_array($result)) {
?>

<table width="500" border="0" cellpadding="2" cellspacing="0" bgcolor="#dddddd">
<tr>
<td bgcolor="#ffffff"><b><?=$db[0]?></b></td>
</tr>
</table>

<table width="500" border="0" cellpadding="2" cellspacing="1" bgcolor="#999999">
<colgroup>
<col width="*">
<col width="100">
</colgroup>

<?php
// 테이블 최적화 실행
$que = "show tables";
$tmp = mysql_db_query($db[0], $que, $dbcon) or die(mysql_error());
while($table = mysql_fetch_array($tmp)) {
$que = "OPTIMIZE TABLE ".$table[0];
mysql_query($que, $dbcon) or die(mysql_error());
?>

<tr bgcolor="#ffffff">
<td style="padding-left:30"><?=$table[0]?></td>
<td align="center">최적화 완료</td>
</tr>

<?php
}
?>

</table>

<br><br>

<?php
flush();
}
?>

</body>
</html>


파로스님꺼는 해보니까 디비양이 많은지는 몰라도
Fatal error: Maximum execution time of 30 seconds exceeded in d:\\apm_setup\\htdocs\\db.php on line 65
이쪽부분에서 에러가 나더군욤..왜글까욤
mysql_query($que, $dbcon) or die(mysql_error());

 
 -.k 맨 상단에 set_time_limit(0); 를....

관련자료

등록된 댓글이 없습니다.
Today's proverb
우리의 꿈은, 뒤에 오는 사람들이 우리를 딛고 우리 위에서 이루게 하는 것입니다. 나는 평생을 창조적인 작업을 위해서 살아왔습니다. 누가 하라고 해서 한 것이 아니라 그것이 나의 삶 그 자체의 즐거움이었기 때문입니다. 현실을 직시하며 현재의 수준을 유지하라. 그리고 더 먼 곳을 향하는 시야를 가져라.