Rumah >pangkalan data >tutorial mysql >mysql数据库碎片整理脚本_MySQL
<?phperror_reporting (E_ALL);mysql_connect("localhost","root","12344321");mysql_query("set names utf8");$resource=mysql_query("show databases");while($row=mysql_fetch_array($resource)){ if($row[0]=='information_schema'||$row[0]=='performance_schema'){//performance_schema continue; } $sql=" use ".$row[0]; mysql_query($sql); $result=mysql_query("show tables"); while($value=mysql_fetch_array($result)){ $sql="optimize table ".$row[0].'.'.$value[0]; $r=mysql_query($sql); if($r){ //echo "ok"; }else{ echo "fail"; } }}?>