Created
September 6, 2018 19:47
-
-
Save sodonnell/464c358fc35ca2f20179f08a18b21c10 to your computer and use it in GitHub Desktop.
convert LIVE mysql tables from MyISAM to InnoDB via mysql cli
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
| #!/usr/bin/env bash | |
| # | |
| # This was commented on the following page: | |
| # https://dev.mysql.com/doc/refman/8.0/en/converting-tables-to-innodb.html | |
| # | |
| # This script/command was tested and found to be harmless/non-destructive, surprisingly. ;-P | |
| # | |
| DBNAME="exampledb"; | |
| DBHOST="localhost"; | |
| DBUSER="someguy"; | |
| mysql -h ${DBHOST} -u ${DBUSER} -p ${DBNAME} -e "show table status where Engine='MyISAM';" | awk 'NR>1 {print "ALTER TABLE "$1" ENGINE = InnoDB;"}' | mysql -h ${DBHOST} -u ${DBUSER} -p ${DBNAME}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment