In this article we are going to cover how to transfer wordpress site from localhost to live server so that to make site public.

There are very easy steps involve to make WordPress site live and we will cover all of them in detail.

Experienced bloggers and developers often make websites using localhost and then upload them to live sever once they are happy with the outcome.

This saves them a lot of time and make trial and error so much fast.

See our article WordPress localhost Tutorial using WampServer for more details.

Before getting started and for absolute beginners, you need to have a domain name and a web hosting package and if you already have one, you are good to go.

If you are still looking for web hosting then We really recommend you Hostgator being one of the best web hosting providers. learningCMS is hosted on Hostgator and we are offering special discount to our visitors.

Click the banner below to get Hostgator web hosting SPECIAL DISCOUNT OFFER only for learningCMS visitors.

Let’s start with our WordPress migration steps.

STEP 1: Export Localhost WordPress Database

WordPress database migration is the most important step. Although you can use plugins like WP Migrate DB but we suggest to export WordPress database manually as it is the most reliable method.

  • From your browser, open phpMyAdmin from the url http://localhost/phpMyAdmin. From the list on the left side, select the database you want to export and click Export from the top menu.
phpmyadmin database
  • On the next screen, leave all the settings on default and click Go.
phpmyadmin export database
  • Download WordPress database as database_name.sql. Keep it in a safe place, we will import this database to new site later on.

STEP 2: Moving WordPress Files to Online Website

The next step is to move WordPress files to your online web hosting. Go to your localhost website folder usually inside www folder. Select all the files and make a compressed zip file.

We are using winrar for this purpose but you can use any software. The point is it should be a zip file.

wordpress zip files
  • Login to your CPanel and then File Manager.
cpanel filemanager
  • Go to your www or public_html directory and click the Upload button at the top.
  • Upload the zip file you just created and extract the files by right clicking on the zip file and choosing Extract.

All extracted files should be on the main of public_html also known as root directory.

Woopoo's Tip

The other way to upload WordPress website from local to server is by using an ftp client. See our detail article ftp setup for WordPress Beginners.

Login to your ftp account and simply drag and drop all folders and files from your localhost website folder to public_html.

This method is not recommended as it will take much more time than uploading a single WordPress zip file to CPanel and simply extract it. The other reason being ftp clients get disconnected anytime which could create another problem.

Anyway whatever method looks more perfect to you, just follow it and all you have to do is to move WordPress files to root directory commonly public_html.

STEP 3: Creating New Database for WordPress

We need to create a new empty database for WordPress now. Let’s do it. We are using Hostgator CPanel but your web hosting CPanel should have same or similar options to do the same tasks.

  • If you already login to CPanel, click Manage Databases.
cpanel manage database
  • Make a new WordPress database by entering a meaningful name. Make a note of this name in a notepad or a text editor. We need this database name later on.
cpanel create database
  • Every database should have a user associated with it. Create a new database user by entering a username and creating a strong password. Make a note of this database user and password also.
cpanel database user
  • You have to add this user to WordPress database now. Click the Add button to add the user to database.
add user to database
  • On the next screen, check the option All privileges and click Make Changes at the bottom.
databasse user

STEP 4: Importing Localhost Database

The database you have created is an empty house right now. We have to import our localhost database into this database to fill it with the data.

  • From CPanel, go to phpMyAdmin and click Import from the top menu. Choose your file you downloaded earlier database_name.sql
phpmyadmin database import

It will fill your new database with all the tables and make an exact copy of your localhost database.


STEP 5: WordPress Important Database Settings

You have successfully copy localhost database to online database but we need to make some changes as some of the values are still pointing to localhost.

  • In phpMyAdmin, click the database name from the left hand side and select wp_options table. We need to change two database entries namely siteurl and home.

Please note we are now in our ONLINE phpMyAdmin not in localhost phpMyAdmin.

wordpress database wp_options
  • Out of the options Edit, Copy and Delete, Select the Edit option for siteurl.
  • Carefully write your website domain name instead of your localhost address. In our case, we have written
wordpress database editing
  • Do the same for home entry and update it as well.

STEP 6: Setting up WordPress Online

Still we left with one last step. We have setup everything but WordPress is still pointing to localhost database and we need to fix it.

  • From your CPanel, go to www or public_html, select wp-config.php file and click Edit from the top menu.
wordpress edit config.php
  • Update the values DB_NAME, DB_USER AND DB_PASSWORD with your new database name, username and password you have created in Step 3. Don’t touch anything else and save the file.

Visit your website in browser, it should be online now. Also try to login to WordPress to see everything is intact and working fine.

From your dashboard, go to Settings > General and without touching anything, click Save Changes. Do the same with Settings > Permalinks

Woopoo's Tip

STEP 7: Fixing WordPress Broken Links and Image URLs

One thing you may have noticed that all of your WordPress links are broken after migration. Same story with image urls.

We have to update and change image urls in database but don’t worry you don’t have to fix it manually. One easy approach is by using Velvet Blues Update Urls plugin to bulk change WordPress URLs.

If you don’t want to use a plugin then instead we will run a SQL query which will fix all of these errors automatically.

  • Login to CPanel and go to phpMyAdmin. Select your database from the left hand side and click SQL from the top menu.
  • Enter the following SQL query and press Go.

Don’t forget to change the parameters with your own localhost folder and your online website domain name.

UPDATE wp_posts SET post_content = REPLACE(post_content, ‘localhost/newsite/’, ‘’);

wordpress sql code

This SQL query will instantly fix broken links and images in WordPress.

Congrats if you really make it until here. Isn’t it like solving a big puzzle? 🙂

We have tried our best to compile all the information on what it takes to move your WordPress blog from localhost to online server.

If any step is unclear to you or you need more information do let us know using the comments below.

Gimme a Share pleeeaase!

Pin It on Pinterest

Share This