findandreplace-180x180

There are times when you have a blog that has 400 posts, and you decided to switch your domain and you were using write-in images for your thumbnails in the custom field. Now you have a huge problem because you need to go and replace each image URL to the new URL. Or lets say you wrote 50 posts and you spelled something wrong. For example WordPress instead of WordPress. Now you can’t possibly go search all 50 posts to change just the uppercase of P. In this post we will show you how you can use an SQL Query for WordPress Database to Find and Replace text with just one click.

findandreplace

You need to go to your phpMyAdmin and select your database. Then click the button SQL. Once you have done that paste the following code:

1 update TABLE_NAME set FIELD_NAME =
2 replace(FIELD_NAME,'TEXT TO FIND','TEXT TO REPLACE')

This will work with any MySQL Database not just WordPress. Make sure that you make a backup of your database before you run this query.

In the example, we will be replacing the text WordPress to WordPress in our posts.

1 update wp_posts set post_content =
2 replace(post_content,'Wordpress','WordPress')

Hit Done, and all will be replaced with one click. This is very helpful, and it can save you a lot of time.

Just please make sure to make a Backup of your Database.

From http://www.wpbeginner.com/