How to migrate a WordPress websitePosted on
Estimated reading time: 3 minutes, 41 seconds
During the stages of developing a website it is sometimes necessary to Migrate WordPress website, for example to change its domain. And guess what – it’s not as difficult as it might seem at first, but I would advise you to back up your website files and database before you start relocating.
Step 1 – Updates
Before we can start relocating our website we have to make sure that our WordPress core and the plugins are updated to the latest releases. We are starting with updating the plugins and continue with the WordPress core update. Make sure to stick to the correct order here!
Step 2 – Plugin “WP Migrate DB”
Now the next step is find and replace the URLs and file paths of our current WordPress website with our new WordPress website. In order to do that in only a few simple steps we are using the WordPress plugin “WP Migrate DB” by Delicious Brains. This plugin exports our database as a MySQL data dump (similar to phpMyAdmin) and automatically finds and replaces our current URL’S and file paths with our new ones.
After we have installed and activated the plugin we can use the plugin under the menu “Tools”. In the first empty field under “Replace” we need to enter the new URL of our website. Important: Make sure you enter it in this format: “//yourdomain.co.uk” – no “http:” or the last “/” after the domain (1). In the second empty field we need to change the location path of our home directory. You can find the path of your home directory in the control panel (cPanel in our case). After the path of our home directory we need to add the folder name of the root. The path of our home directory and the root can differ from control panel to control panel. In the end it should look something like this: “/home/yourwebsite/public_html” (2).
Now we are ready to download the database to our computer. Before you hit the “Export” button make sure you have ticked the “Replace GUIDs” and “Exclude spam comments” options under the “Advanced Options” menu (3).
Step 3 – Moving your files
The next step is to move our actual WordPress files from the current web hosting control panel to the new one. Therefore, we go to the current control panel, select all files and compress them to a zip-file. Afterwards, we are downloading it and saving it on our computer. After we have done that make sure to delete the zipped file from your control panel again.
Next, we are going to the new control panel, select our root folder, upload the zipped file we have just downloaded and extract it in the root folder. If there is an index.html file feel free to delete it because there will be no need for it anymore. Now all our files and pages should be in the new control panel.
Step 4 – The database
The last step is to create a new database on our new user control panel. In cPanel you can create a new database under the menu “MySQL Databases”. Create a new database and a new user there. Also don’t forget to assign the new user to the new database otherwise it won’t work.
Next, we have to go back to your files in the control panel, select “wb-config.php” and select the edit-mode. Edit and save the following three lines to match them up with our database and database user you have just created: DB_NAME, DB_USER and DB_PASSWORD
Now we are going to import the database we have downloaded during step 2 into our new database. For that we have to go to the menu “phpMyAdmin”, select the correct database and click the “import”-tab in the menu. Simply select the zipped file we downloaded earlier with the WordPress plugin, import it and we should be good to go!
So there you go – a short, four step (more or less) tutorial on how to relocate your WordPress website. Have fun and don’t forget to do a backup before you start!