Pentium10 Pentium10 - 1 year ago 105
MySQL Question

How to convert all tables from MyISAM into InnoDB?

I know I can issue an alter table individually to change the table storage from MyISAM to InooDB.

I am wondering if there is a way to quickly change all of them to InnoDB?

Answer Source
    // connect your database here first 

    // Actual code starts here 

        WHERE TABLE_SCHEMA = 'your_database_name' 
        AND ENGINE = 'MyISAM'";

    $rs = mysql_query($sql);

    while($row = mysql_fetch_array($rs))
        $tbl = $row[0];
        $sql = "ALTER TABLE `$tbl` ENGINE=INNODB";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download