如何批量将mysql数据库转为MyISAM

分类:CentOS运维 阅读:94775 次

建立一个PHP文件,将INNODB指转为MyISAM.

<?php
// your connection
mysql_connect(“localhost”,”db_user”,”db_pass”);
mysql_select_db(“drupal_db_name”);

// convert code
$res = mysql_query(“SHOW TABLES”);
while ($row = mysql_fetch_array($res))
{
foreach ($row as $key => $table)
{
mysql_query(“ALTER TABLE ” . $table . ” ENGINE=MyISAM”);
echo $key . ” =&gt; ” . $table . ” set to MyISAM<br />”;
}
}
?>