Created
February 25, 2014 17:08
-
-
Save markshust/9213270 to your computer and use it in GitHub Desktop.
PHP script to convert MySQL tables from MyISAM to InnoDB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.