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
이슬비가 내리고 있다. 당신은 밖에 나가서 우산을 편다. 그것으로 충분하다.“구질구질하게 또 비가 오는군!” 이런 말을 한들 무슨 소용이 있는가. 비도, 구름도, 바람도 결코 마음대로 되지 않는데 어째서 “비 한번 시원스럽게 내리는군”하고 말하지 못하는가. <<날마다 행복해지는 255가지 이야기>> (알랭)