MySql - Convert InnoDB to MyISAM Storage Engine of Database

前端 未结 7 695
盖世英雄少女心
盖世英雄少女心 2020-12-24 12:39

How to convert database storage engine from InnoDB to MyISAM on MySQL? I found so many sites which convert the storage engine of datab

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-24 13:12

    to make it permanent, add to my.cnf (few locations depending on context)

    /etc/my.cnf

    default-storage-engine= MyISAM

    for safety, output the db list with show databases;

    in my case, using php for quickie..

    $db = mysql_connect('localhost','someadmin','somepass');
    $dbs = array();
    $dbs[] = 'test';
    $dbs[] = 'myImportantDb';
    
    foreach($dbs as $v){
        mysql_select_db($v);
        $q = mysql_query('show tables');
        $tables = array();
        while($r = mysql_fetch_row($q)){
                $tables[] = $r[0];
        }
        foreach($tables as $t){
            echo "do $v.$t\n";
            mysql_query('ALTER TABLE `'.$t.'` ENGINE=MyISAM;');
        }
    }
    mysql_close($db);
    

提交回复
热议问题