Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

How to Move WordPress From Local Server to Live Site

Last updated on by
Follow WPBeginner on YouTube
How to Move WordPress From Local Server to Live Site

Developing a WordPress site locally can help speed up the development process. In the past, we showed you how to install WordPress on your Windows computer using WAMP and on Mac using MAMP. Once you have finished the development on localhost, the next step is to move the site live. In this article, we will show you how to move WordPress from local server to a live site. By using this process, you would be able to migrate all of your content (posts, pages, images, etc), themes, as well as plugins from local server to a production site.

Before we start, we must let you know that you can make this migration from local server to a live site easier by using one of the two plugins: BackupBuddy or Duplicator. In this article, we will show you how to move WordPress from local server to live site manually, so you can learn the process. However to make the process easy for us, we rely on BackupBuddy when we do this on a day to day basis.

Pre-Steps

In order for you to migrate your locally developed WordPress site to a live server, you need to have two things. First is the local server. We are assuming that you have a WordPress site running on local server, and you have full access to it. Next, you would need to have web hosting that supports WordPress, so you can migrate your content over.

You would need to have a FTP program and know how to use FTP, so you can upload your content to the live site.

Note: the screenshots used in this article are from WordPress hosting providers that have cPanel.

Step 1: Export Local WordPress Database

First thing you need to do is export your local WordPress database. We will be using phpMyAdmin to do that. If you are unfamiliar with it, then you might want to take a look at our guide to WordPress database management using phpMyAdmin. Simply go to http://localhost/phpmyadmin/ and click on your WordPress database. Next, click on the Export button from the top menu bar.

Exporting WordPress database using phpMyAdmin

In the Export Method option choose custom, which will provide you with more options to export your database. Select all tables to export and gzipped for compression. Scroll down to the bottom of the page and press the Go button to download your database.

Step 2: Uploading WordPress Files to Live Site

Now open an FTP client and connect to your live site. Once you are connected to your live site, make sure you upload the files in the right directory. For example if you want the site to be hosted on yoursite.com, then you would want to upload all files in your public_html directory.

Now select your local WordPress files and upload them to your live server.

Uploading WordPress from localhost to live site

Step 3: Creating MySQL Database on Live Site

While your FTP client is uploading your WordPress files, you can spend this time on importing your database to the live server. Most WordPress hosting providers offer cPanel to manage your hosting account, so we will show you how to create a database using cPanel. Log in to your cPanel dashboard and click on the MySQL databases icon which can be found in the databases section.

Creating MySQL database in cPanel

On the next screen, create a database by entering a name for your database.

Create a new database

After creating a database, scroll down to MySQL users section and create or add an existing user to the database. After adding the user, cPanel will take you to set MySQL privileges for that user. Simply grant all privileges to the user.

Create a new MySQL user or Add an existing user to the Database

Step 4: Importing WordPress Database on Live Site

Next step in the process is to import your WordPress database. Go to your cPanel dashboard, scroll down to the databases section and click on phpMyAdmin. This will take you to phpMyAdmin where you want to click on the database you created earlier. phpMyAdmin will show your new database with no tables. Click on the Import tab in the top menu. On the import page, click on choose file button and then select the gzipped database file you saved in step 1. Lastly, press the Go button at the bottom of the page. phpMyadmin will now import your WordPress database.

Importing database in phpMyAdmin

Step 5: Changing the Site URL

Now you need to change the site URL, so you can setup your live WordPress site. In your phpMyAdmin, look for the wp_options table in your database that we just imported in step 4. If you changed your database prefix, then instead of wp_options it might be {prefix}_options.

Click on the browse button next to wp_options or the link that you see in the sidebar to open the page with a list of fields within the wp_options table. See screenshot below:

Browse wp_options in phpMyAdmin

Under the field options_name, you need to look for siteurl. Click the Edit Field icon which can be found at the far left at the beginning of the row.

Edit siteurl in phpMyAdmin

When you click the edit field, an edit field window will appear. In the input box for option_value, you will see the URL of your local install probably something like: http://localhost/test. Carefully insert your new site url in this field, for example: http://www.wpbeginner.com

Save the field by clicking the Go button.

Next, you need to replicate this step for the option name: home. The wp_options page can be a few pages long, so simply find the home tab. Usually it is on the second page which you can navigate to by clicking on the pagination arrows in phpMyAdmin.

Update the home url to be the same as your siteurl.

Step 6: Setting Up your Live Site

Now that we have imported the database, and all of our content should be uploaded, it is time to configure WordPress. At this time, your site should be showing an Error Establishing Database Connection error. To fix this, connect to your website using an FTP client and edit wp-config.php file. Provide the database name, user and password you created earlier in Step 3. Save the wp-config.php file and upload it back to your server. Visit your website, and it should be live now.

Login to your WordPress admin panel, and go to Settings » General. Click save Options. This will ensure that the site url is corrected anywhere else that needs to be.

Then go to Settings » Permalink and click Save to ensure that all post links are working fine.

Step 7: Fixing Images and Broken Links by updating Paths

Whenever you are moving a WordPress site from one domain to another, or from local server to a live site, you would face broken links and missing images issue. You can either use the SQL query or use the Velvet Blues WordPress plugin.

For those who want to do it via SQL, here is a simple SQL query that should solve this problem:

UPDATE wp_posts SET post_content = REPLACE(post_content, 'localhost/test/', 'www.yourlivesite.com/');

Simply go to phpMyAdmin, click on your database and then click on SQL from top menu. Write this query but don’t forget to change it with your own local site and live site URLs.

Fixing WordPress images and broken URLs after moving to live site

That’s all, hopefully your live site will be up and running by now. Checkout your site to make sure that every thing is working fine as expected. For troubleshooting and questions feel free to leave us a comment below and we will try to help out as much as we can.

If you are doing this on a regular basis, then we highly recommend that you get BackupBuddy because it will make your life easy. You will thank us for that later :)


Editorial Staff at WPBeginner is a team of WordPress lovers led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »
  • http://www.wpbeginner.com/ WPBeginner Staff

    Please go to the admin area -> Settings and make sure that you are using the correct Site Address and WordPress Address.

  • http://www.wpbeginner.com/ WPBeginner Staff

    Seems like your domain is not yet ready or you have uploaded WordPress in the wrong directory on your web server. Please contact your web hosting provider for support.

  • Elliot Lee

    HELP!!! Why am I receiving this error in step 4?

    SQL query:


    — Database: `wordpress`

    — ——————————————————–

    — Table structure for table `wp_commentmeta`

    CREATE TABLE `wp_commentmeta` (

    `meta_id` bigint( 20 ) unsigned NOT NULL AUTO_INCREMENT ,
    `comment_id` bigint( 20 ) unsigned NOT NULL DEFAULT ‘0’,
    `meta_key` varchar( 255 ) DEFAULT NULL ,
    `meta_value` longtext,
    PRIMARY KEY ( `meta_id` ) ,
    KEY `comment_id` ( `comment_id` ) ,
    KEY `meta_key` ( `meta_key` ) ) ENGINE = InnoDB DEFAULT CHARSET = utf8 AUTO_INCREMENT =1;

    MySQL said:

    #1046 – No database selected

    • http://www.wpbeginner.com/ WPBeginner Staff

      Before you can run this query you need to select the database you want to run it on. If you are using phpMyAdmin then select the database and then click on the SQL to run the query.

  • http://www.wpbeginner.com/ WPBeginner Staff

    You can try deactivating all the plugins at once by renaming the /wp-content/plugins directory. Here is a tutorial.

    Usually plugins store settings in WordPress database so hopefully most of your settings will not get affected by the change.

  • orangedrum

    I’m wondering the same thing. Just uploading my files didn’t work and when I try and re-export the database I’m getting an error telling me these databases already exist. Help!

  • santhosh

    thanks a lot it was easy and helpful for any beginner like me

  • http://www.wpbeginner.com/ WPBeginner Staff

    are you sure you have your site URL as your mysql host? it is usually localhost or a subdomain on your site like mysql.example.com. If you are unsure ask your hosting provider.

  • Wasim

    After completing all the above steps , do in need to replace my index.html file

    • http://www.wpbeginner.com/ WPBeginner Staff

      No, you don’t.

  • http://www.wpbeginner.com/ WPBeginner Staff

    The most probably cause is that your new database is empty, WordPress successfully connects to your new database. Then it finds out that the database is empty and assumes that its a new site. What you need to do is to import your old database. After that you will need to change your sitename and site url and update your links. See this guide.

  • http://www.wpbeginner.com/ WPBeginner Staff

    Those changes will be lost if you uploaded an older version of the database from your local server.

  • http://avantgardian.org/ Andrew Avantgardian

    Worked like a charm, except i didn’t even need the last step (the MySQL query) for some reason all my links and pictures were fine after the transfer, perhaps it has something to do with the new version of WordPress.

    Anyways thanks for this guide

  • http://www.wpbeginner.com/ WPBeginner Staff

    This article assumes that your live site is actually developed on localhost, so it does not assume that you have already taken down a live site to to work on it.

    In case you are working on a live site by creating a local copy on your computer. Then this strategy is usually used to only work on site’s layout, adding new features, or testing some functionality. This way you can work on your website without modifying any data and when you move the site from localserver to livesite your database usually remains unchanged.

    Hope this helps

  • http://www.wpbeginner.com/ WPBeginner Staff

    WordPress.com is still managing your domain name. You can transfer your domain’s registration to your new webhost. Or you can simply update nameserver information for your domain on WordPress.com and point it to your new webhost. Please see the instructions in our guide on how to properly move your WordPress.com blog to WordPress.org

  • http://www.wpbeginner.com/ WPBeginner Staff

    Yes you could just simply install WordPress and then upload your theme.

  • http://www.wpbeginner.com/ WPBeginner Staff

    You can not edit theme or install plugins on WordPress.com. Please see our guide on the difference between WordPress.com vs WordPress.org

  • http://www.wpbeginner.com/ WPBeginner Staff

    Installing WordPress using Sofaculous is not a requirement,

  • Ferdinand

    I want to set up a site on local host which I want to manage locally. I would write the articles and upload them to webhost after I write them. Do I need to update the site and php database in the way that you mentioned above every single time I write a post? Or is there any way to upload only the files that got changed? This I want to know since it would be very time saving to manage the site offline for me.

  • Rizky M R

    My site has working, but i can’t open any page and post of my website, and also the image still doesn’t show up after the sql query fix

  • Charlie Barnett

    Hi, I have found your explanation extremely useful and have managed to trasnfer my locally hosted wp site live. However when I try step 6 to login I can’t seem to login and it throws the following error:

    Internal Server Error

    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Please contact the server administrator, and inform them of the time the error occurred, and anything you might have done that may have caused the error.

    More information about this error may be available in the server error log.

    Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

    Does this make sense have I missed something in my upload?

    Thanks Charlie

    • http://www.wpbeginner.com/ WPBeginner Support

      Please take a look at how to fix the internal server error in WordPress. Due to generic nature of this error, it usually does not tell you where to look for the problem.

  • wanda serros

    My site is up but it’s still not completely functional. When I click on some of my images to get an enlarged view I get a message saying ‘The requested content cannot be loaded. Please try again later.’

    I’ve looked in my database and I see that there are still instances of ‘localhost’…. in some fields. I did run the Update to ‘post_contents’ query already. Should I run additional queries to change every mention of ‘localhost’ in the database to my website address?

    Thank you. Your site has been very helpful.

    • Timothy

      Ofcourse, replace every instance of localhost and localhost/

  • Lisa

    I figured out how to upload the database, finally. made those text editor changes within the sql file first. Now I’ve done all of the other steps, including changing the wp_options “home” and “siteurl” … and also editing the wp_config.php file from within my live c panel file manager and making those updates. I still get an “error establishing database connection”. I did notice when I installed wordpress on my new hosted site, it created its own database (ss_1). Should i delete that one?

    • http://www.wpbeginner.com/ WPBeginner Support

      The most common reason for the error is usually incorrect password, database, username or host information. It has nothing to do with other databases on your mysql server, so there is no need to delete them. Make sure you are entering correct information for your database in your wp-config.php file.

  • Karlo

    I followed your instructions to make a local copy of my live website (the other way around).

    The only problem I’m experiencing is that the stylesheet isn’t loading and that my images arent showing up, not even on WP backend.

    Do I need to run another SQL query to fix this?