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
Special WordPress Hosting offer for WPBeginner Readers
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 experts 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 »

Comments

  1. Jesh says:

    Hi there,
    absolute frustration has caused me comment for help. I have been trying to upload my site from local to live using MAMP and FileZilla. I have followed your steps as well as others MANY times but still to no avail. Your guide is very good and I have followed the whole thing to the end but every time I go to view my site it comes up with the domain then .preview.services . The page is an “index of” page and it won’t let me go any further. I have tinkered around with the settings but really don’t know what to do except smash my computer. Can you recommend anything? …a sledgehammer?

    • WPBeginner Support says:

      When uploading files from your computer to your website, make sure you are uploading them in the correct directory. If you are not sure, then ask your web hosting service provider. Typically its called /public_html/ but it varies from one web host to another.

      Also make sure that you are uploading only your WordPress files and not including the MAMP files and directories in the upload.

  2. Gale says:

    Just wanna let you know, you guys are freaking awesome! This is such a great tutorial! I’d been stuck for days with the links not working and you’re the only ones mentioning saving the settings! Thank you so much!

  3. Rajat says:

    Hi,

    I just started using Hostgator. I had created a website using WAMP. I have the .sql file and the wordpress files. I am still not able to get that website show up on my domain. Can you please tell me what can i do in this regard.

    Thanks for your help.

  4. Gary Pippin says:

    Hi,

    I have created a wordpress website and it is still not live. When i open the url in browser it says “This url is under construction : Coming Soon”.. Could you please help me with this issue.

    Thanks
    Gary

    • WPBeginner Support says:

      1. Your site may have a plugin installed that is used to display this page.
      2. Your domain name may not be pointing to the directory where you have your WordPress site.

      Please contact your web host, they will be able to help you better.

  5. nick says:

    i dont get it. like my site is live but it still have broken links and images. im trying to fix it with the my sql quary way but everything i fill in as local site and live site URLs it says 0 rows affected and theres nothing that changed. So can you explain which urls i have to fill in exactly

    • Julian says:

      Hello Nick,
      Are you using the query on the live phpmyadmin dashboard?
      Make sure you do it on the live site through Cpanel and not on your local environment.

  6. Kishokumar says:

    Great word buddy, i didn’t know about this until now. Thank you so much.

  7. Learner says:

    Hi, I’m learnin wordpress, I’m trying to migrate my website to a new domain and new host. Should I need to activate wordpress on my new hosting account before I load from my backup website. Thanks for your help.

    • WPBeginner Support says:

      Depends on what kind of backup you have. If it is an XML or RSS file, then you should first install WordPress and then import your content from those files. If the back contains database and complete WordPress files, then you need to extract and upload WordPress files to your new host and then import database from backup.

  8. Priyangga says:

    All works great!! but the theme doesn’t completely loaded, is the any issues? please help!!

  9. Yuri says:

    Thanks for the article, but ima kinda desperate here…

    Lost 4 hours of working trying to figure out why in my webserver the index page keeps BLANK, even after connected the database. And my admin page gives me the error not found, i’ve been searching for a solution and nothing helps.

    thanks in advance

  10. Steve says:

    Worked perfectly! Thanks.

  11. Croiche Jim says:

    thanks a lot :)

    cheers!

  12. precious osasumwen says:

    pls help. i get this error when i try to access my phpadmin in my wamp server.

    phpMyAdmin – Error

    Cannot start session without errors, please check errors given in your PHP and/or webserver log file and configure your PHP installation properly. Also ensure that cookies are enabled in your browser.

    what do i do sir

  13. Sneha says:

    Hi,

    I have created my website on my local server and also I have used action method to navigate to different pages. But on these action methods I have given localhost permalinks only as destination address. So do I have to replace it with live address everywhere in the code or is there some method by which i can replace it at once.

  14. Chris Cal says:

    I’m not one to usually comment but this is an excellent post.
    Great work Syed and team. Greatly appreciated.
    Cheers, Chris.

  15. Leslie says:

    It was the .htaccess file!!! But I had to upload a completely new file. Thanks!!!

  16. Courtney says:

    Any tutorials for when you have forgotten your phpMyAdmin login info? I am stuck at the beginning! It has been a while since I have needed to login and cannot for the life of me remember. I used this site as a tutorial to set up but cannot figure out how to reset. I have seen some tutorials to reset but I am afraid it is going to mess things up as I am not an expert. Any suggestions or tutorials you can point me to? TIA

  17. Tyane says:

    I’m stuck on step 6. I edited the wp-config. file and uploaded it. It gave me six errors, with most of them beginning with, ” unexpected beginning of statement” followed by the position each error is listed. I’m very new to this and my IT husband is out of town till Friday.

  18. barshan hassan says:

    Thanks… I love u

  19. leon says:

    works really well!

  20. geeuy says:

    great tutorial!
    worked like a charm!

  21. ashkan says:

    hi there tnx for this article

    i did all these steps and my site is up now but when i click on other pages or links i faced this eror
    (Internal Server Error)

    in fact I just can see the homepage

    can You tell me about This?

    • Thatguy91 says:

      I had the same issue, go to the permalinks page and click the save button. I think it needs to “resave” the permalinks again somewhere once migrated.

  22. mtahirian says:

    Hello,
    I have uploaded my site live. but unfortunately i can’t go to wordpress admin. the wordpress admin is working fine on local server. it has problem keep telling that : Warning: Cannot modify header information – headers already sent by (output started at /home/………/public_html/wp-content/plugins/js_composer_theme/js_composer.php:1) in /home/porseshresearch/public_html/wp-includes/pluggable.php on line 1228

    Please Help

    • WPBeginner Support says:

      Seems that js_composer_theme plugin is not working. Connect to your website using FTP and then download the plugin to your computer. After that you can delete the plugin from your server. This should resolve the issue.

      • mtahirian says:

        Thanks for responding.
        I did, as told. but the whole site is smashed up and can’t get the design correct. I need the COMPOSER.

  23. wpbeginner says:

    Thank you very much for your wonderful tutorial.
    I am having a problem where my website is only accessible through blog.example.com but not accessible through example.com/blog
    May I know what can be done to solve this?

    • WPBeginner Support says:

      Your blog is hosted as a subdomain. You will need to export it to your main domain.

      • wpbeginner says:

        My subdomain folder is in public_html folder.
        May I know where should I export it for it to be in my main domain?
        Your help is greatly appreciated.

  24. awoyemi ayomide says:

    thanks it help me a lot

  25. Lars Breum Hansen says:

    I am stuck at step 6. My site is live, but instead of going to my main page, It show my themes default main page, at gives me an 404 (because it can’t find posts, but my main page is set to be static). And I can’t login as admin, becuase then it gives me the 500 internal error?

  26. Kim Macc says:

    Hi.

    This article is great thank you!! I have done everything and the site is live but the pages are not linking/working i get an ‘internal server error’

    please help me fix this as soon as possible. have done the SQL query but to no avail.

  27. AP says:

    Make sure hidden files are copied over as well as part of Step 2

  28. Ebune says:

    i had a problem in the step where i am to change localhost/test. to my site name. i cant really see an edit but to change that stuff. also, when i try to upload my database, it gives me an error. please can anyone help??? am in a deep shit right now

  29. Mayur says:

    My website is
    I have changed my server , i took backup of wp files and mysql before my server service expired. Now i am on a new server, uploaded and extracted wp files in public_html, i am. Getting an error – error establishing database connection, hoe should i solve this error?

  30. Caitlin says:

    Hi! I ran into a problem in step 6: “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.”

    I did that and it didn’t work, so I started to edit where it said “localhost” and changed it to my domain.

    I’m a totally newbie so any help would be appreciated!

    • WPBeginner Support says:

      Try using localhost as your MySQL Host

      define( ‘DB_HOST’, ‘localhost’ );

  31. ananta says:

    owh… maan… this is what i am looking for all day long… finally found your article. it’s very helpful. now, my site is live. thank you. good work by the way.

  32. Raj jain says:

    Hi,

    How can I solve this error. Reply urgently.

    Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in /home/sitename/public_html/wp-includes/pomo/mo.php on line 236

  33. Elise says:

    Hello, I’ve been following all these steps but when I’m doing the export but when I’m importing in my OVH database I can only see wp_commentmeta and wp_comments instead I’ve selected all tab during the export and choose custom and the gzipped format
    Do you know what’s happening here?

  34. Amey mankar says:

    Thank You so much. It help me alot.

  35. Mboule A says:

    I tried changing localhost to my domain name but it isn’t going. I need help. I’ve tried both methods. Both the plugins and using the SQL code

  36. Bessong william says:

    thanks you for you tutorial, but am still a beginner in web developping, i need you to teach me with a plugin like BackupBuddy or Duplicator or what ever!!!, how to migrate my website from local to live production site

  37. cmunozro says:

    Can’t access my website.
    Error al establecer una conexión con la base de datos (unable to connect to data base)

    I try accessing thorough the IP as the domain is not transfered yet. I’m not sure in the wp_options and in wp_config what data should I use.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.