Created
October 26, 2018 11:07
-
-
Save tfirdaus/d67a03687217a7f462d516c5750a4fdd to your computer and use it in GitHub Desktop.
Convert MyISAM tables to InnoDB with WP-CLI
This file contains 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 | |
# 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
https://guides.wp-bullet.com/converting-wordpress-database-tables-from-myisam-to-innodb-with-wp-cli/