Skip to content

Instantly share code, notes, and snippets.

@trueqap
Created July 31, 2020 13:44
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save trueqap/dcb33ccae01e0c0e5da34ab00a4050fa to your computer and use it in GitHub Desktop.
WordPress MyISAM to InnoDB with CLI
#!/usr/bin/env bash
WP_TABLES=($(wp db query "SHOW TABLE STATUS WHERE Engine = 'MyISAM'" --allow-root --silent --skip-column-names | awk '{ print $1}'))
for WP_TABLES in ${WP_TABLES[@]}
do
echo "Converting ${WP_TABLES} to InnoDB"
wp db query "ALTER TABLE ${WP_TABLES} ENGINE=InnoDB" --allow-root
echo "Converted ${WP_TABLES} to InnoDB"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment