Expert Group of programming

How to fix weird characters on WordPress blog after migration?

Posted by : Heycode Tech | Posted in : wordpress, WordPress Functions | Dec 3,2015 | 0 comments

Sometime when we take a backup of MYSQL and upload on another MYSQL then some special character have come automatically like  ⠀ and our content becomes meaningless. So for removing this type of special character from our content,we need to follow the described steps.

Here I ‘m describing the two methods and you can select anyone.These two methods are :-
1:- MYSQL Backup Method .
2:- Table update Method (Recommended).

Now sometime developer asked that why the Confliction occurs i.e why special character’s are inserted in our content automatically .Here I is the reason .

Now as we know that default MYSQL character encoding isLatin1 while the WordPress has utf-8. This conflict between character encoding turned out to be the cause for such weird characters inside my site’s articles.

So if such type of problem occurs then follow these methods.

1:- MYSQL Backup Method :

Step -i)- Now when you have installed the WordPress then these two lines are necessary exists in root file : wp-config.php :

define('DB_CHARSET', 'utf8'); /* Database Charset to use in creating database tables. */
define('DB_COLLATE', ''); /* The Database Collate type. Don't change this if in doubt. */

Step -ii)- I assume that you are taking the backup through command prompt then follow the steps-

mysqldump -u root -p --opt --quote-names --skip-set-charset --default-character-set=latin1 wordpress > wordpress.sql

Now username : root : and databaseName : wordpress : and backup file is : wordpress.sql.
Now you can change the – default character set = latin1 to utf8.

Step -iii)- After completing the backup, you need to upload the backup file into the MYSQL database, then use this command.

mysql -u root -p --default-character-set=utf8 wordpress < wordpress.sql

Again,Now username : root : and database Name : wordpress : and backup file is : wordpress.sql.

2:- Table update Method (Recommended).

It is the very easy and simple method for removing the weird character. By using of this, you need to login in MYSQL and select the database. After selecting the database, you need to run these query and it will automatically remove the weird character.

Step-1 : Login into MYSQL .

mysql -uroot -p 

Step-2 : Select the database name

use #databasename#

Step-3 : Run these query .

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, '“', '');

As per own requirement, you need to add the replacement content.Now in above query,I have added the blank i.e nothing so it will only remove special characters.

Conclusion :
Hope so it will help for removing the weird character but still if you have any query then please share with me .


Author information - Heycode Tech

Every world can ask question and my website registered user give the suggestion.

See all posts by Author

Connect to author

About us

Heycodetech is a platform where you can ask any questions related to the programming like PHP,jQuery, MYSQL,HTML , CSS and more Here is the Expert group of programming.