Remove weird characters from your WordPress database

Remove weird characters from your WordPress database

Sometime you might find you end up with weird characters in you content after you migrate a WordPress data base, the following SQL code can be run.

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_posts SET post_title = REPLACE(post_title, '“', '“');
UPDATE wp_posts SET post_title = REPLACE(post_title, '”', '”');
UPDATE wp_posts SET post_title = REPLACE(post_title, '’', '’');
UPDATE wp_posts SET post_title = REPLACE(post_title, '‘', '‘');
UPDATE wp_posts SET post_title = REPLACE(post_title, '—', '–');
UPDATE wp_posts SET post_title = REPLACE(post_title, '–', '—');
UPDATE wp_posts SET post_title = REPLACE(post_title, '•', '-');
UPDATE wp_posts SET post_title = REPLACE(post_title, '…', '…');
UPDATE wp_posts SET post_title = REPLACE(post_title, 'Â', ");
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, '…', '…');
UPDATE wp_posts SET post_content = REPLACE(post_content, 'Â', ");