An easy way to search and replace domain names in database records

Recently I had to move a WordPress site from one domain to another (‘beta’ to ‘www’), when using the Media tool, it automatically adds the current full site URL to the post database records.

This is a very useful SQL snippet to do a full search and replace on the wp_posts table.

update wp_posts set post_content = replace(post_content,'http://beta.olddomain.com/','http://www.newdomain/');

This should see you right 🙂