SQL Search and Replace: Use PhpMyAdmin
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.
- Login to phpMyAdmin and select your database
- Click the SQL tab
- 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");
- 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!