Migrating a WordPress site to a different domain can be a bit of a pain. The standard way to do this is detailed in this tutorial on the wordpress website.
If you’re using phpmyadmin to update the database directly the only two changes you have to make are to the site_url and home option-name‘s in wp_options. Make sure you change the option_value for each of these to the new address.
One of the problems you may come across is that your old posts may reference the old domain in same way. If you want to update these then it’s laborious and manual task of editing them in the database – which can be error prone, unless done carefully. You can run a SQL update to update the domain in the post_content column of the wp_posts table as follows:
| SQL | | copy | | ? |
UPDATE wp_posts SET post_content = REPLACE(post_content, 'olddomain.com', 'newdomain.com'); |
I used this method to update the guid column to reference my new domain instead of my old domain.
Make sure you backup your database before running this. It’s a pretty easy process to do the backup of a MySQL database.
| Bash | | copy | | ? |
mysqldump -u username -p -v old.db > old.sql |
If you’re also renaming your database in relation to your domain name move you can use the following:
| Bash | | copy | | ? |
mysqldump -u username -p -v old.db > old.sql |
mysqladmin -u username -p create newdb |
mysql -u username -p newdb < old.sql |
