Dukeo » WordPress » SQL Search and Replace: Use PhpMyAdmin

SQL Search and Replace: Use PhpMyAdmin

Steven 2 responses WordPress

I recently moved one of my websites to a brand new domain. It was sitting on a domain I registered in my early years in the blogosphere, and to be honest, this domain named just plained sucked! So I wanted to move this blog to a keyword rich domain. There are plenty of ways to migrate your blog from a domain to another, but not being a code guy, I struggled with one simple issue.

In a lot of my posts, I was saying the name of my website, pretty much the same way I am doing with Dukeo. Let’s say it’s a way of branding my website name by doing some name-dropping. The problem is that, after migrating to the new domain, I had plenty of referencies to the old domain in the articles.

After searching for a while, I found this step by step guide to update all the posts at once.

  1. Login to phpMyAdmin and select your database
  2. Click the SQL tab
  3. Enter the following in the run SQL Query text box (replacing table_name, table_field, search_string and replace_string with your actual information:
    UPDATE table_name SET table_field = replace(tablefield,"search_string","replace_string");
  4. Click go to process the changes and update your SQL database

Here is a WordPress SQL Query database example for reference:

UPDATE wp_posts SET post_content = replace(post_content,"OldDomain.com","NewDomain.com");

This line of code literally saved me hours of post editing, I hope this will help you too!

If you enjoyed this article,
Get email updates

Join for Free »


  1. Polo

    Hey Steven,
    Very simple and useful tutorial!
    Best regards!

    1. Hey, thank you Polo!

      I realized that from time to time you may face this kind of small issue and struggle for hours to get a fix… So, I’m glad if I can help :)

      This is what Dukeo is about after all: helping and giving back to the community!