Migrating a WordPress website from a local server to a live server can be quite simple if done the right way and can be a nightmare too if the wrong procedures are used. During my rookie days as a WordPress developer i used to export the content from the localhost WordPress dashboard then make a new installation on a live server and try to import the xml file. One thing i would always notice is broken links which would take me back to the procedure of uploading images one by one and i really found it hard to fix all the links.

How to transfer Wordpress site from localhost to live server

It’s only until i learned how to make the migration the right way that everything became easy for me. From this time i would take less than 5 minutes to migrate a website from a local server to a live server depending on the size of the content and data speed. Below, i explain the steps of migrating a website from a local server to a live server but before i continue i assume you know how to:

  • Deal with MSQL Databases
  • Upload files on a server
  • Edit PHP My Admin

If you don’t know, no worries! Just follow the exact steps below and i promise you will have your migration complete without any errors. In case you get stuck during the process simply drop me a comment below and i will respond to you immediately.

Step 1 – Zip your WordPress Files

The first steps involves compressing your data on the local machine and making them ready for upload. In this step, Zip the folder that has your WordPress installation.

Step 2 – Export Database

Open Php MyAdmin and locate the database that holds the data for your WordPress website then export it the way it is. Further edits will be made from a live server.

Step 3 – Upload the WordPress Files on new Server

The third step involves uploading the zipped WordPress files into a server and extracting it in the Public Html folder. You could use a FTP Client like FileZilla to transfer the compressed file but make sure the files are extracted on the Public_Html folder or else your website will show CGI or a blank page.

To test your WordPress site, visit it’s url and you should see a database error. If it shows the error this means the files have been uploaded well.

Step 4 – Retrieving the Database

First and foremost, you will have to create a database on the server. I assume you know how to create a database and assign a user with all privileges to it. Don’t forget to copy the user credentials and the database name as you will need them later to configure WordPress.

Step 5 – Import Content

Once the database is created, open Php MyAdmin and locate the database you just created. Open it and import the sql file you exported from the live server.

Step 6 – Edit the Database entries

This step is one of the most vital steps in configuring your WordPress site on the server or else it won’t work. There are some entries you will have to change in the database before your site can go live.

Open the Wp_Options (depends on database prefix but by defualt the table is name wp_options) table and edit the first two entries which are: Siteurl and home. Simply change the url’s in their respective fields to the new URL of your website. Don’t forget to include a protocol i.e http://, https:// depending on the kind of protocol you are using. That sums up the database.

Step 7 – Edit Wp-Config file

Navigate back to Public_Html directory of your website and locate a file named wp-config. This file is found in the root of your WordPress installation. Right click on it and click on the edit option then fill in the fields with their corresponding details:

define(‘DB_NAME’, ‘Enter database name here’);
define(‘DB_USER’, ‘Enter database username here’);
define(‘DB_PASSWORD’, ‘Enter Database user mysql password here’);
define(‘DB_HOST’, ‘localhost’);
define(‘DB_CHARSET’, ‘utf8’);
define(‘DB_COLLATE’, ”);

You can now visit your website’s URL in your browser and it should be live. Incase the database connection error persists it means you either skipped one of the steps or you didn’t do it right. Look through the article and correct what you didn’t do right.