Sunday, 22 February 2015 22:15

Alter MySQL database tables to INNODB script

Written by

This simple script allows you to use PHP to change your databaase tables from MyISAM to INNODB.

<?php
// connect your database here first
    $dbhost = 'localhost';
    $dbuser = '*********';
    $dbpass = '*********';
    $dbname = '*********';
	
    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
    
    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);
    }
?>
Read 477 times Last modified on Sunday, 22 February 2015 22:22