Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save fernandoaleman/76ae43ef54f32aa6cf4d to your computer and use it in GitHub Desktop.
Save fernandoaleman/76ae43ef54f32aa6cf4d to your computer and use it in GitHub Desktop.
Converting MySQL Database Contents to UTF-8
# First create a dump of your MySQL database
mysqldump -u [user] -p database_name > database_name.sql
# Convert the data
iconv -f iso-8859-15 -t utf8 database_name.sql > database_name_iconv.sql
# Import the database
mysql -u [user] -p database_name < database_name_iconv.sql
# If you still have some specific characters that do not display
# correctly, you can update them individually.
# This is an example of updating a single quote
UPDATE `table_name` SET `column_name` = REPLACE(column_name, '’', '&rsquo;');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment