Melodist Melodist - 4 months ago 9
MySQL Question

Unwanted special characters in WordPress site after export/import

I made a copy of a WordPress site (originally at http://infinitelypossible.net) and changed the site URL to http://blissyourmoney.com.

Now there are unwanted special characters in the database, especially in the _posts table. Characters like quotation marks have been converted to other odd symbols, and some characters have just been added, seemingly randomly.

I double checked the export/import settings on WordPress.org for PHPMyAdmin and tried the export/import again with the correct settings, to no avail. (The only setting that needed to be changed was unchecking "Extended Inserts" under the Data heading.)

Answer

As I stated in my comment above: make sure that DB_CHARSET and DB_COLLATE in wp-config.php on the new site matches the old site.

You responded that DB_CHARSET and DB_COLLATE only existed in your new instal of WordPress and that removing them from the new wp-config.php fixed the issue. The issue was that you were instructing WordPress to use a different character set by having DB_CHARSET and DB_COLLATE than what the database was setup with.

The WordPress Codex states, https://codex.wordpress.org/Editing_wp-config.php:

If DB_CHARSET and DB_COLLATE do not exist in your wp-config.php file, DO NOT add either definition to your wp-config.php file unless you read and understand Converting Database Character Sets. Adding DB_CHARSET and DB_COLLATE to the wp-config.php file, for an existing blog, can cause major problems.

So removing the definition to fix the issue was the right course of action and should solve the problem as you merely reset them to default values.

Comments