Page 1 of 1

from ''MyISAM'' to ''InnoDB'' and conversely

Posted: Sat Mar 14, 2015 7:41 pm
by vestacp89
Hello,

How i can change ''MyISAM'' to ''InnoDB'' ?
and conversely ?

Thanks.

Re: from ''MyISAM'' to ''InnoDB'' and conversely

Posted: Sat Mar 14, 2015 10:20 pm
by skurudo
mysql / phpmyadmin - http://dev.mysql.com/doc/refman/5.6/en/ ... nnodb.html

or magic php scripts (source)

Code: Select all

<?php
    // connect your database here first 
    // 

    // Actual code starts here 

    $sql = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
        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";
        mysql_query($sql);
    }
?>

Re: from ''MyISAM'' to ''InnoDB'' and conversely

Posted: Sun Mar 15, 2015 9:39 am
by vestacp89
skurudo wrote:mysql / phpmyadmin - http://dev.mysql.com/doc/refman/5.6/en/ ... nnodb.html

or magic php scripts (source)

Code: Select all

<?php
    // connect your database here first 
    // 

    // Actual code starts here 

    $sql = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
        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";
        mysql_query($sql);
    }
?>
Hello,

this script:

Code: Select all

<?php
    // connect your database here first 
    // 

    // Actual code starts here 

    $sql = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
        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";
        mysql_query($sql);
    }
?>
I need to paste this code make .php file and run ?
I don't know what all i need edit in this code,
can you pls tell what i need to edit in code, my database name is ''auto_db'' ?

Thanks.

Re: from ''MyISAM'' to ''InnoDB'' and conversely

Posted: Sun Mar 15, 2015 2:09 pm
by skurudo