<?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"; } }}?>
登录后复制
当一个服务器上有较多网站时 。可能会用得上。在执行之前请备份