How to migrate WordPress site from localhost to server

To migrate WordPress site from local installation to a production server follow this few simple steps. We are going to show you how to do it using popular tools – phpMyAdmin and NotePad++.

1.      Export database

-        Navigate to phpMyAdmin (http://localhost/phpmyadmin/) in your browser

-        Login to your local database

-        Click Databases

-        Click on your WordPress database name

-        Click Export

-        Leave Quick option

-        Click Go button

-        Save your sql dump file on your drive

2.      Replace service URL

You need to change your url address from http://localhost/ or http://localhost/wordpress/ or something similar to your production URL – http://www.yoursite.com/

-        Open sql dump file which you created in step 1 with NotePad++

-        Push Ctrl+H on your keyboard – this will start Replace dialog

-        In the Find what input field enter your local URL which is going to be something like http://localhost/ or http://localhost/wordpress/

-        In the Replace with input field enter your WordPress production URL like http://www.yoursite.com/

-        Pay attention to the last slash ‘/’ sign to replace URL in the correct way

-        Click Replace All

3.      Replace installation path (optional)

//Since there are plugins and themes out there that use wordpress installation path you might need to perform this step.

Perform step 2 to replace files installation path with the one that matches your production site wordpress folder. Remember to use full path.

For example replace C:\Development\wamp\www\wordpress with /home/users/yoursite/public_html/wordpress.

4.      Import database

-        Navigate to phpMyAdmin which controls your production database server

-        Click Databases

-        Provide your database name

-        Provide encoding

-        Click Create

-        Click on newly created database

-        Click Import

-        Click Browse and navigate to Your modified sql dump file

-        Click Go

5.      Modify wp-config.php file

-        Modify wp-config.php file to match your needs


define('DB_NAME', '[PRODUCTION_DATABASENAME_HERE]');

define('DB_USER', '[PRODUCTION_USERNAME_HERE]');

define('DB_PASSWORD', '[PRODUCTION_PASSWORD_HERE]');

define('DB_HOST', '[PRODUCTION_HOSTNAME_HERE]');

6.      Upload instance code to server

Upload Your local WordPress files to the server to the installation directory which you have set in the step 3.

11 Responses to "How to migrate WordPress site from localhost to server"

  1. shirish says:

    CREATE TABLE IF NOT EXISTS `wp_commentmeta

    This error can’t permit me to move wordpress site to another pc OR even in host server. Pls. provide the solutions.

    Reply
    • itcuties says:

      Hello,

      you need to give us more info about the error. This is just a CREATE SQL statement fragment. Are you getting this error while importing you database with the phpmyadmin tool or the mysql command line client?

      Cheers,
      itcuties

      Reply
  2. ananda says:

    HOW TO UPLOAD??????????

    Reply
    • itcuties says:

      Hello Ananda,
      you can use any FTP client you like to upload data to your server.

      Have a nice day,
      itcuties

      Reply
  3. Abdul Waudud Chowdhury says:

    Hi Itcuties,

    Thanks for the great post, its really helpful.

    I do everything from Step -1 to Step- 6, (Skip step-3) as you describe.
    Everything is ok & the Site is UP.

    But the problem is that except home page, all the page are redirect to my local server page :(

    Even i can’t login to my site Dashboard , it also redirect to my local wordpress login page.
    Site Url : “http://learn2earn.web44.net”

    Can you please suggest me what’s the problem & how i can fix this problem.

    Best Regards
    Abdul Waudud

    Reply
    • itcuties says:

      Hello Abdul,

      does your database dump file contain any “http://localhost” strings? If so you need to replace them with the “http://learn2earn.web44.net” strings.

      Let us know it it helps.

      Cheers,
      itcuties

      Reply
  4. Abdul Waudud Chowdhury says:

    Hi itcuties,

    It works now

    Many many thanks

    Abdul Waudud

    Reply
  5. Dayo says:

    trying to upload database i got this errors below: ANY HELP?


    Database: `soundtunes`

    – ——————–

    – Table structure for table `gs_commentmeta`

    CREATE TABLE IF NOT EXISTS `gs_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: Documentation

    #1046 – No database selected

    Reply
    • itcuties says:

      It seems that you are not selecting a database in your import script. Try adding set [your-database-name-here] at the beggining of your script.

      Reply
  6. rydweb says:

    hey ,
    i followed all your step in this video , but it appears ,to create a new title ,, ans login with password .
    and atfer creatin , he did not show me all plugins , with contents .
    any help ? Plz thx

    Reply
    • itcuties says:

      Hi there, you need to check if your database contains correct paths for your plugins. Remember that each plugin may use their own set of tables. It’s hard to say what’s wrong in your case. Please provide us with more info, like what are the plugins that you want to migrate etc.

      Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Java by Example App is available at Google Play Store NOW