How to convert all tables from MyISAM into InnoDB?

If you omit the ENGINE option, the default storage engine is used. Normally, this is MyISAM, but you can change it by using the --default-storage-engine server startup option, or by setting the default-storage-engine option in the my.cnf configuration file.

You may also want to change the default storage engine just for the current session. You can do this by setting the storage_engine variable:

SET storage_engine=INNODB;

PHP Code to change the database engine

    // connect your database here first 

    // Actual code starts here 

        WHERE TABLE_SCHEMA = 'your_database_name' 
        AND ENGINE <> 'InnoDB'";

    $rs = mysql_query($sql);

    while($row = mysql_fetch_array($rs))
        $tbl = $row[0];
        $sql = "ALTER TABLE $tbl ENGINE=INNODB";

Related Posts

  • 77
    MYISAM: MYISAM supports Table-level Locking MyISAM designed for need of speed MyISAM does not support foreign keys hence we call MySQL with MYISAM is DBMS MyISAM stores its tables, data and indexes in diskspace using separate three different files. (tablename.FRM, tablename.MYD, tablename.MYI) MYISAM not supports transaction. You cannot commit and…
    Tags: myisam, innodb
  • 43
    90% of the time, this error is due either to the MySQL Server not running, or else firewall configuration on the Windows server blocking access on port 3306 (or whatever port your MySQL instance is configured to use). Error: 2003 (CR_CONN_HOST_ERROR) Message: Can't connect to MySQL server on '%s' (%d)
    Tags: server, connect, configuration
  • 42
      [root@mysqlDB]# mysqladmin -u root -p create eduguru Enter password:****** This will create a MySQL database eduguru. This is a simple example to create database called eduguru. Example: <?php $dbhost = 'localhost:3036'; //If mysql server is on same server $dbuser = 'root'; //mysql user who has the permission to create database $dbpass…
    Tags: database, $sql, php
  • 41
    PHP 5 and later can work with a MySQL database using: MySQLi extension (the "i" stands for improved) PDO (PHP Data Objects) Earlier versions of PHP used the MySQL extension. However, this extension was deprecated in 2012. Open a Connection to MySQL   Example: <?php $servername = "localhost"; $username =…
    Tags: database, php, table, code, $sql
  • 40
    To enable the query log, put this in /etc/my.cnf in the [mysqld] section log = /path/to/query.log #works for mysql < 5.1.29 Also, to enable it from MySQL console SET general_log = 1; Remember that this logfile can grow very big on a busy server. update: With mysql 5.1.29+ , the log option is deprecated. To specify…
    Tags: set, table, database, server, file

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: