Sometimes you want to move on your WordPress site from one server to another server. The Most complex part is database when you want to move a WordPress site to another location because WordPress save the base URL in the Database and we can say it saves the absolute path of URL instead of relative path when stores some parameters in database.Here I come with the solution to deal with such situations.
All these values in the database will need to be changed when WordPress is moved but It is not at all hard to do once you get the idea and if you are technical.
Once the site has been moved, first of all, we need to make the change on a wp-config.php file.This value can be changed via WordPress Options page, but if you no longer able to access to old site URL, you have to modify the value via MySQL database.
So, are you ready? Let’s see steps are as follows.This approach is not the new installation of WordPress.
Steps to update wp-config.php
- Open your database configuration file wp-config.php which is in the root folder of your WordPress.
- You need to replace DB_NAME, DB_USER, and DB_PASSWORD with your live server database details which you created for your new host/server and if require DB_HOST( database host name).
- After replacing above informtion, save the updated copy of wp-config.php
To Update the Database
To update WordPress options with the new site location, use the following SQL command.
NOTE: Make sure you have a backup of your database and copies of all your plugins and theme before you update the database. If the database transfer is not successful, will result to broke your sites.
You need to access your phpMyAdmin or log in to the DB server and upload old server database. After uploading old Database run below UPDATE Query in your phpMyAdmin. Using this, You can run WordPress site easily.
Here is the database Query to replace the Base URL of domain:
UPDATE wp_options SET option_value = replace (option_value , 'http://www.oldsite.com' , 'http://www.newsite.com') WHERE option_name = 'home' OR option_name = 'siteurl'; UPDATE wp_posts SET guid = replace (guid , 'http://www.oldsite.com' , 'http://www.newsite.com'); UPDATE wp_posts SET post_content = replace (post_content , 'http://www.oldsite.com' , 'http://www.newsite.com'); UPDATE wp_postmeta SET meta_value = replace (meta_value , 'http://www.oldsite.com' , 'http://www.newsite.com');
Congratulations! Now you’re done and you can go to your new WordPress blog’s URL.After you complete these steps, WordPress can be used normally.of course, You need to do some optimization.
If you face any other problems concerning the relocation of WordPress database to another server, leave a message in the comments below, I would like to sort out the issues.