Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Fix double encoded utf-8 in mysql

By: iarmin on Jun 16th, 2011  |  syntax: Bash  |  size: 0.35 KB  |  views: 1,149  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/bash -e
  2.  
  3. DB_HOST="$1"
  4. DB_USER="$2"
  5. DB_PASSWORD="$3"
  6. DB_NAME="$4"
  7.  
  8.  
  9. mysqldump -h "$DB_HOST -u "$DB_USER" -p"$DB_PASSWORD" --opt --quote-names \
  10.    --skip-set-charset --default-character-set=latin1 "$DB_NAME" > /tmp/temp.sql
  11.  
  12. mysql -h "$DB_HOST" -u "$DB_USER" -p"$DB_PASSWORD" \
  13.    --default-character-set=utf8 "$DB_NAME" < /tmp/temp.sql