Home Snippets MySQL How to convert all tables from MyISAM into InnoDB?

Search MySQL

    Login Form


    You can use this script to convert *all* tables from Type MyISAM to InnoDB. Note that the Joomla 2.5 tables #__finder_tokens & #__finder_tokens_aggregate are both of type MEMORY, and will also be converted to INNODB. I'd recommend to change those back to MEMORY after using this script.

    source: http://stackoverflow.com/questions/3856435/how-to-convert-all-tables-from-myisam-into-innodb


    Snippet code:

    // connect your database here first 
        $dbhost = 'localhost';
        $dbuser = 'root';
        $dbpass = 'root';
        $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
        $dbname = 'databasename';
    // Actual code starts here 
        $sql = "SHOW tables";
        $rs = mysql_query($sql);
        while($row = mysql_fetch_array($rs))
            $tbl = $row[0];
            $sql = "ALTER TABLE $tbl ENGINE=INNODB";


    blog comments powered by Disqusblog comments powered by Disqus
    Joomla Templates by JoomlashackJoomla Templates by Joomlashack