If you change domain with your blog, but decided to stick to the same database 1, probably you will have to update several URLs in your entries.

I’m a lazy person and everything which can be done automatically, will be be automated. Replacing links or words in your WordPress database table is a really simple act. Of course, you should first backup your database 2.

Open your CPanel or Plesk backend and move to the Database —> phpMyAdmin area. Select your database here and move to wp_posts

The syntax to replace strings/data/words/whatevah in your database is simple:

update tablename set field = replace(field,'search_for_this','replace_with_this');

In my case I had to change the URL from serialrecidivism.com; to ifranky.com/amifamousnow, the string looked as this:

update wp_posts set post_content = replace(post_content,'http://serialrecidivism.com','http://ifranky.com/amifamousnow');

go, phpMyAdmin will now tell you how many strings have been changed and you can admire how all your links are supposed to work again, intra-entry.

Congratulations, after some Googling, you now have become a MYSQL authority! 3

  1. You have imported your database at your new hoster, or just changed all while staying with the same hoster []
  2. Lazy people obviously use this trick []
  3. Yeah, right []
Published on February 4th, 2008 and labelled Geek-Tricks. This entry has been viewed 241 times.
Taxonomy: , , ,

No Responses to “Replace Data in MYSQL Table”

Leave a Reply