Skip to content

Instantly share code, notes, and snippets.

@sodonnell
Created September 6, 2018 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sodonnell/464c358fc35ca2f20179f08a18b21c10 to your computer and use it in GitHub Desktop.
Save sodonnell/464c358fc35ca2f20179f08a18b21c10 to your computer and use it in GitHub Desktop.
convert LIVE mysql tables from MyISAM to InnoDB via mysql cli
#!/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