We’re always launching new sites for clients, many times those sites happen to be wordpress. In one instance, a client wanted to try it themselves and hit a wall. After migrating a WordPress
site to a new URL either live or to a production or development server, the new URL strings in the mysql database need to be changed and updated in the various mysql
database tables. For instance, mywebsite.com/dev to myrealdomain.com
This is a (somewhat) advanced method that just uses the whole mysql database (rather than a WordPress internal function) and is best suited for a straight swap. So you would copy all the WordPress files/folders to the new destination, set the correct ownership to those files = then do the database swap.
WordPress Database Swap Wapa Doo Wop
Do a mysql database export of the old database on the old server, create a new blank database on the new server, import the old data either in phpmyadmin
or mysql directly in the command line. Using PHPmyadmin is alot easier than it seems, just go into your Cpanel and navigate to it. Then select the database powering your site, then you can press “SQL” and drop this code in. The reason we are saying to copy it all, is so that you can experiment without breaking everything.
Make sure you have the new database selected, then run some sql updates and replacement commands on the tables notably, wp_options, wp_posts, wp_postmeta.
Use the code as below and swap in your old and new URLs, no trailing slashes. Also if necessary change the table prefix values where applicable (ie wp_ )
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');