WordPress Multisite Change Domain Name of Subsite using SQL

I have been working on migrating a website I did for a friend a while ago from an old ASP.NET application I built to my WordPress Amazon EC2 Instance over the last few weekends as the old server we were using for hosting is being retired. I have been working on a temporary domain whilst getting the site up and running using the subdomain dev.cafeontherye.co.uk and now it is time to migrate to www.cafeontherye.co.uk so I thought I would put the steps up here to update WordPress Multisite change Domain name.

First step was to update the DNS settings and change the IP of www to point to the IP address of my WordPress instance on Amazon EC2. Whilst waiting for this to propagate I needed to update all of the settings in WordPress to point to the new domain. I use the WordPress MU Domain Mapping plugin for this so navigated to my Network Admin > Settings > Domains and added a new entry to point to www and made it the primary for that domain. I then logged into MySQL workbench and ran the following.

update [dbname].[wp_site_id]_options
   set option_value = replace(option_value, '[oldsiteurl]','[newsiteurl]');
update [dbname].[wp_site_id]_posts
   set post_content = replace(post_content, '[oldsiteurl]','[newsiteurl]');
update [dbname].[wp_site_id]_posts
   set guid = replace(guid, '[oldsiteurl]','[newsiteurl]');
update [dbname].[wp_site_id]_postmeta
set meta_value = replace(meta_value, '[oldsiteurl]','[newsiteurl]');

Waited around four hours for everything to propagate and Cafe On The Rye lives again in it’s new responsive WordPress form.

Music To Write This Code To

Now the weather is getting colder there is nothing better to warm the soul than Fake Blood mixing up of old tunes sampled in classic Hip Hop tracks.

Leave a Reply

Your email address will not be published. Required fields are marked *

2 comments on “WordPress Multisite Change Domain Name of Subsite using SQL