Last active
June 15, 2017 16:18
-
-
Save psbrandt/f57e572d026b9f8a725bea2316ff1ce9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/bin/bash | |
| if [ "$#" -ne 2 ]; then | |
| echo "Usage: ./clean-database-dump.sh <INPUT_FILENAME> <OUTPUT_FILENAME>" | |
| exit 1 | |
| fi | |
| input=$1 | |
| output=$2 | |
| cp $1 $2 | |
| echo "[1/5] Fixing CHARSET..." | |
| sed -i "s/CHARSET=.*\;/CHARSET=utf8\;/g" $2 | |
| echo "[2/5] Fixing CHARACTER SET..." | |
| sed -i "s/CHARACTER\ SET\ [^\ ]*/CHARACTER\ SET\ utf8/" $2 | |
| echo "[3/5] Fixing COLLATION..." | |
| sed -i "s/SET\ collation_connection.*=\ [^@].*\ \*/SET\ collation_connection\ =\ utf8_general_ci\ \*/" $2 | |
| echo "[4/5] Remove CREATE DATABASE..." | |
| sed -i "s/CREATE\ DATABASE.*//" $2 | |
| echo "[5/5] Remove USE..." | |
| sed -i "s/USE\ \`.*//" $2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment