Оптимизация Mysql таблиц всех сразу (MyIsam php)
По желанию можно вставить и repair table
Code (php)
-
-
<?php
-
-
$time = $time[1] + $time[0];
-
$start = $time;
-
-
//Connection variables :
-
$h = ‘localhost’;
-
$u = ‘root’;
-
$p = ‘password’;
-
-
$dummy_db = ‘mysql’;//The php->mysql API needs to connect to a database even when executing scripts like this. If you got an error from this(permissions), just replace this with the name of your database
-
-
-
$res = mysql_db_query($dummy_db, ‘SHOW DATABASES’, $db_link) or die(‘Could not connect: ‘ . mysql_error());
-
{
-
$dbs [] = $rec [0];
-
}
-
-
foreach ( $dbs as $db_name )
-
{
-
echo "Database : $db_name \n\n";
-
$res = mysql_db_query($dummy_db, "SHOW TABLE STATUS FROM `" . $db_name . "`", $db_link) or die(‘Query : ‘ . mysql_error());
-
{
-
if ( $rec[‘Data_free’] > 0 )
-
{
-
$to_optimize [] = $rec[‘Name’];
-
}
-
}
-
{
-
foreach ( $to_optimize as $tbl )
-
{
-
}
-
}
-
}
-
-
$time = $time[1] + $time[0];
-
$finish = $time;
-
?>
-

(2 голосов, в среднем: 4 из 5)