If you’re anything like me, you occasionally have to re-import your WordPress blog database into your [new] server. For whatever reason, WordPress imports the database and replaces all apostrophes, quotation marks and other characters into weird, unrecognizable gibberish. You might recognize these characters as â€, “, ’, ‘ and plenty more. Luckily, I found a great fix for this from a friendly blog on the web.
Simply login to your phpMyAdmin (usually from your control panel, aka Cpanel in most cases), select the WordPress database, then select ‘SQL’ at the top navigation bar.
How to modify your WordPress database to fix the weird characters
In the SQL query field, enter the following:
UPDATE wp_posts SET post_content = REPLACE(post_content, '“', '“');
UPDATE wp_posts SET post_content = REPLACE(post_content, '”', '”');
UPDATE wp_posts SET post_content = REPLACE(post_content, '’', '’');
UPDATE wp_posts SET post_content = REPLACE(post_content, '‘', '‘');
UPDATE wp_posts SET post_content = REPLACE(post_content, '–', '–');
UPDATE wp_posts SET post_content = REPLACE(post_content, '—', '—');
UPDATE wp_posts SET post_content = REPLACE(post_content, '-', '-');
UPDATE wp_posts SET post_content = REPLACE(post_content, '…', '…');
UPDATE wp_comments SET comment_content = REPLACE(comment_content, '“', '“');
UPDATE wp_comments SET comment_content = REPLACE(comment_content, '”', '”');
UPDATE wp_comments SET comment_content = REPLACE(comment_content, '’', '’');
UPDATE wp_comments SET comment_content = REPLACE(comment_content, '‘', '‘');
UPDATE wp_comments SET comment_content = REPLACE(comment_content, '–', '–');
UPDATE wp_comments SET comment_content = REPLACE(comment_content, '—', '—');
UPDATE wp_comments SET comment_content = REPLACE(comment_content, '-', '-');
UPDATE wp_comments SET comment_content = REPLACE(comment_content, '…', '…');
Source
Hit ‘Go’. Your window should refresh and show you what and how the query affected your database. That’s it! Go to your blog, refresh, and look at the cleanliness.
For me, I had over 50 fixes. A great little SQL script for anyone.