If you omit the
ENGINEoption, the default storage engine is used. Normally, this is MyISAM, but you can change it by using the--default-storage-engineserver startup option, or by setting thedefault-storage-engineoption in themy.cnfconfiguration 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
<?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 <> 'InnoDB'";
$rs = mysql_query($sql);
while($row = mysql_fetch_array($rs))
{
$tbl = $row[0];
$sql = "ALTER TABLE $tbl ENGINE=INNODB";
mysql_query($sql);
}
?>