Skip to content

Instantly share code, notes, and snippets.

@markshust
Created February 25, 2014 17:08
Show Gist options
  • Select an option

  • Save markshust/9213270 to your computer and use it in GitHub Desktop.

Select an option

Save markshust/9213270 to your computer and use it in GitHub Desktop.
PHP script to convert MySQL tables from MyISAM to InnoDB
<?php
$conn = mysql_connect('server', 'username', 'password');
mysql_select_db('database', $conn);
$sql = "SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE engine <> 'InnoDB'";
$rs = mysql_query($sql);
while ($row = mysql_fetch_array($rs)) {
$tbl = $row[0];
$sql = "ALTER TABLE $tbl ENGINE=INNODB";
mysql_query($sql);
}
@markshust
Copy link
Author

Note, do not run this as root, otherwise it will try to update all database tables on your server, not just for the connected database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment