Skip to content

Instantly share code, notes, and snippets.

@tfirdaus
Created October 26, 2018 11:07
Show Gist options
  • Save tfirdaus/d67a03687217a7f462d516c5750a4fdd to your computer and use it in GitHub Desktop.
Save tfirdaus/d67a03687217a7f462d516c5750a4fdd to your computer and use it in GitHub Desktop.
Convert MyISAM tables to InnoDB with WP-CLI
#!/usr/bin/env bash
# Author Mike https://guides.wp-bullet.com
# Purpose - Convert MyISAM tables to InnoDB with WP-CLI
# create array of MyISAM tables
WPTABLES=($(wp db query "SHOW TABLE STATUS WHERE Engine = 'MyISAM'" --silent --skip-column-names | awk '{ print $1}'))
# loop through array and alter tables
for WPTABLE in ${WPTABLES[@]}
do
echo "Converting ${WPTABLE} to InnoDB"
wp db query "ALTER TABLE ${WPTABLE} ENGINE=InnoDB"
echo "Converted ${WPTABLE} to InnoDB"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment