Skip to content

Instantly share code, notes, and snippets.

@tuanphpvn
Last active August 4, 2016 00:55
Show Gist options
  • Save tuanphpvn/bb57303bae49c142e16e to your computer and use it in GitHub Desktop.
Save tuanphpvn/bb57303bae49c142e16e to your computer and use it in GitHub Desktop.
Convert current database (not support utf8) to Support UTF8 #Mysql #UTF8
mysqldump -u root -pyourpass --default-character-set=latin1 -c --insert-ignore --skip-set-charset your_database > dev.db
for i in dev; do iconv -f ISO-8859-1 -t UTF-8 <$i.db >${i}8.db; done
for i in *8.db; do perl -pi -w -e 's/CHARSET=latin1/CHARSET=utf8/g;' $i; done
for i in your_database; do mysql --user=root --password=yourpassword --execute "DROP DATABASE $i; CREATE DATABASE $i CHARACTER SET utf8 COLLATE utf8_general_ci;"; done
mysql --user=root --password=yourpassword --max_allowed_packet=16M --default-character-set=utf8 your_database < dev8.db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment