SHARE
TWEET

Fix double encoded utf-8 in mysql

iarmin Jun 16th, 2011 1,480 Never
  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
RAW Paste Data
Top