convert innodb to myisam

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • convert innodb to myisam

    login via ssh to your server
    create a file myisam.sh
    Code:
    nano myisam.sh
    insert this code:
    Code:
    #!/bin/bash
    
    MYSQLCMD=mysql
    
    for db in `echo show databases | $MYSQLCMD | grep -v Database`; do
            for table in `echo show tables | $MYSQLCMD $db | grep -v Tables_in_`; do
                    TABLE_TYPE=`echo show create table $table | $MYSQLCMD $db | sed -e's/.*ENGINE=\([[:alnum:]\]\+\)[[:space:]].*/\1/'|grep -v 'Create Table'`
                    if [ $TABLE_TYPE = "InnoDB" ] ; then
                            mysqldump $db $table > $db.$table.sql
                            echo "ALTER TABLE $table ENGINE = MyISAM" | $MYSQLCMD $db
                    fi
            done
    done
    chmod the myisam.sh
    Code:
    chmod 0775 myisam.sh
    run it:
    Code:
    ./myisam.sh

  • #2
    How about login on database before executing the loop on myisam.sh ??
    i get error since i'm not loged in on a specific database , the code would not execute.

    Comment


    • #3
      it works for me when i login as a root user to my server

      Comment

      Working...
      X