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

Search MySQL


    Login Form



    follow_us-a

    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

    MySQL

    Snippet code:

    <?php
    // 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';
        mysql_select_db($dbname);
    
    // 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";
            mysql_query($sql);
        }
    ?>
    

    Comments:


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