Update xenForo Tables To InnoDB From MyISAM

Quick script to update to InnoDB tables

  1. BamaStangGuy
    Compatible XenForo Versions::
    • 1.0
    • 1.1
    • 1.2
    • 1.3
    • 1.4
    If you had InnoDB disabled when you created your database and either installed xenForo or imported a xenForo database into it, then all the tables are MyISAM, which is not what the default XenForo tables are setup as.

    This php script will update the tables that need to be InnoDB to that database format.

    PHP:
    <?php
    $db 
    mysql_connect('localhost','username','password');
    if(!
    $db) echo "Cannot connect to the database - incorrect details";
    mysql_select_db('database');
    $result=mysql_query('show tables');
    $tables_to_ignore = array('xf_import_log','xf_search_index','xf_session','xf_session_admin','xf_attachment_view','xf_session_activity','xf_thread_view');
    while(
    $tables mysql_fetch_array($result)) {
        foreach (
    $tables as $key => $value) {
            if(!
    in_array($value$tables_to_ignore)){
                
    mysql_query("ALTER TABLE $value ENGINE=innodb");
            }
        }
    }
    echo 
    "Your database tables have been changed to innodb!";
    ?>
    Note: Check any add-ons and make sure that they need to be InnoDB. If not, add them to the ignore section so that they are not changed.