Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dannygsmith/9e5a57f5fa22f6c47723e4385142b80e to your computer and use it in GitHub Desktop.
Save dannygsmith/9e5a57f5fa22f6c47723e4385142b80e to your computer and use it in GitHub Desktop.

Revisions

  1. @robinnorth robinnorth revised this gist Jul 27, 2015. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions wordpress_utf8mb4-to-utf8.sh
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,10 @@
    DB="your_database_name"
    USER="your_db_user"
    PASS="your_db_pass"
    HOST="database_hostname"
    (
    echo 'ALTER DATABASE `'"$DB"'` CHARACTER SET utf8 COLLATE utf8_general_ci;'
    mysql -p$PASS -u $USER "$DB" -e "SHOW TABLES" --batch --skip-column-names \
    mysql -p $PASS -u $USER -h $HOST "$DB" -e "SHOW TABLES" --batch --skip-column-names \
    | xargs -I{} echo 'ALTER TABLE `'{}'` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;'
    ) \
    | mysql -p$PASS -u $USER "$DB"
    | mysql -p $PASS -u $USER -h $HOST "$DB"
  2. @robinnorth robinnorth created this gist Jun 25, 2015.
    9 changes: 9 additions & 0 deletions wordpress_utf8mb4-to-utf8.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    DB="your_database_name"
    USER="your_db_user"
    PASS="your_db_pass"
    (
    echo 'ALTER DATABASE `'"$DB"'` CHARACTER SET utf8 COLLATE utf8_general_ci;'
    mysql -p$PASS -u $USER "$DB" -e "SHOW TABLES" --batch --skip-column-names \
    | xargs -I{} echo 'ALTER TABLE `'{}'` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;'
    ) \
    | mysql -p$PASS -u $USER "$DB"