• Blog

    Latest from our Blog

  • Tools

    Our Favourite WP Tools

  • Hosting

    Recommended Web Hosts

  • Coupons

    Get great money off deals

  • Themes

    WordPress Theme Directory

  • Plugins

    WordPress Plugins Directory

  • Promote

    Your WordPress Product

Us WordPress geeks have a strange addiction: how to use WordPress to the fullest! This is what keeps us up at 1 AM experimenting with new plugins, themes and codes. Usually, we carry out these tests from our home/office (if my job is WordPress) computer and once we find something we like its time to implement it on our website. For instance, if you were developing a new theme for a client, you would probably use your home computer. In the past, we showed you how to setup WordPress locally using XAMP.
Transferring an entire installation of WordPress from one host (say your PC’s localhost) to another (remote shared/dedicated hosting server) is error prone and can be easily messed up if not done carefully.

In this post I will show you how to move your WordPress installation from localhost to a remote server using phpMyAdmin. This process requires a set number of applications to be available on both the servers.

Requirements

  1. phpMyAdmin v3 or higher
  2. cPanel on the remote host. 99% of the hosting companies come with cPanel.
  3. We assume that you have an installation of WordPress in your localhost and a remote web hosting server with cPanel & phpMyAdmin.

Okay so lets get started …

Export WordPress Database from localhost using phpMyAdmin

I am using the WAMP server module for my localhost. Ensure that localhost is online and open the following link in your browser:
http://127.0.0.1/phpmyadmin/

Select the proper database click on the “Export” tab. To know which database your WordPress installation is using, open wp-config.php from your WordPress installation directory and check the name under: ‘DB_NAME’.

01-move-wordpress-db-name

01-move-wordpress-phpmyadmin

Thus in this tutorial, I would select the yoursitename_wp database.

  1. Under the Export tab, you should see “Export Method”.  Select the 2nd option i.e. “Custom – display all possible options.”
  2. Next, under “Output”, select “gzipped” as the Compression method
  3. Leave all other setting unchanged and select “Go”.
  4. Your browser should download a file called “yoursitename_wp.sql.gz”The database name varies, but the extension remains the same, i.e. .sql.gz.

1

Create an archive of the WordPress installation folder:

Now that we have a the database backed up, let’s take care of the easy part. Simply navigate to your WordPress installation directory, select all the files (Ctrl+A) and create a zip archive. Let’s call it wp.zip. Note that the size of wp.zip may vary from one installation to another since some people might have heavy Media content (for example: 5 megapixel photo galleries).
Therefore, there’s no fixed size for wp.zip.

Create a new database and user using MySQL Database Wizard in cPanel:

2

Open your remote web server’s cPanel and select the “MySQL® Database Wizard”.  In the first step, enter a desired name. I have chosen “wplift” in this case.
NB: cPanel automatically adds a prefix to every database name and user. In this tutorial it is “explorin_”. Therefore the correct database name would be “explorin_wplift”.

3

Click Next to proceed to Step 2. Here we create a database user and password. I recommend using an unusual username (for security reasons) and always use the password generator.

Record these values and select “Create User”.

For the purpose of this tutorial, the username is “explorin_uzzer” with password “?0aAsMOcJG_m“.

4

In the Final step, you assign the newly created user certain privileges for database access. Check “ALL PRIVILEGES” and click on “Next Step”. This creates a new database & user and assigns the required privileges to that user.

Import the Database to remote server using phpMyAdmin

Now that we have created the database and user, let us import the content of the previous database to the new one. Open the remote web server’s phpMyAdmin and select the newly created database. In our case it would be explorin_wplift. Click on “Import”.

5

Under this tab, upload the previously exported “mysitename_wp.sql.gz” file under “File to Import” option. Ensure that Do not use AUTO_INCREMENT for zero values checkbox in checked. Click on “Go”.

If the import goes successfully, you should get a similar success notification:

01-move-wordpress-phpmyadmin-r-import-success

Unpack the archive in the correct folder:

If we want our WordPress installation to be available under http://yoursitename.com/; we must extract the archive wp.zip  in the base directory i.e. public_html.

However, if we wanted WordPress to be available under http://yoursitename.com/blog, then we would have extracted the files under public_html/blog.

Edit wp-config.php.

This is the single most important part. You should carefully read the previous steps before altering the contents of this file. You essentially need to change the following predefined constants:

  1. The database name i.e. DB_NAME
  2. The user of the database name i.e. DB_USER
  3. The user’s password i.e. DB_PASSWORD

And define two new constants:

  1. WP_SITEURL
  2. WP_HOME

We will use the values that we have defined in the previous steps of this tutorial so that you can get an idea. This would be the exact working configuration of our tutorial.

/** The name of the database for WordPress */
define('DB_NAME', 'explorin_wplift');

/** MySQL database username */
define('DB_USER', 'explorin_uzzer');

/** MySQL database password */
define('DB_PASSWORD', '?0aAsMOcJG_m');

/** Defining WP_HOME and WP_SITEURL */
define('WP_HOME', 'http://yoursitename.com/');
define('WP_SITEURL', 'http://yoursitename.com/');

PS: The single quotes, semicolons and brackets are important, do not remove them.

To sum up the wp-config.php step this is how it should look:

/** The name of the database for WordPress */
define(‘DB_NAME’, ‘your complete database name’);

/** MySQL database username */
define(‘DB_USER’, ‘your database username’);

/** MySQL database password */
define(‘DB_PASSWORD’, ‘your database password’);

/** Defining WP_HOME and WP_SITEURL */
define(‘WP_HOME’, ‘your site’s URL’);
define(‘WP_SITEURL’, ‘your site’s URL’);

Conclusion

If everything goes will, you should be able to see your WordPress site under http://yoursitename.com. If you run into any problem make sure to recheck every step. Remember, a missing semicolon can render your site inaccessible. Leave us a comment if you need further help!


Disclosure: This page may contain affiliate links for which we will receive compensation if a purchase is made via the link.

Author:

Sourav is a WordPress enthusiast, an avid gamer and a sitcom collector. His playlists include heavy metal, electronic, and new-age tracks. When he's not online, he's spending quality time with his friends and family.

Leave Yours +

12 Comments

  1. randomguy

    Thanks. This is even better than the RELOCATE method. Also, for all the URLs buried throughout post content. I use the Velvet Blues Update URLs plugin (http://wordpress.org/extend/plugins/velvet-blues-update-urls/).

  2. Steve

    Like Randomguy said, you still need to update any static links that may be using “localhost”. I didn’t know you could declare home and site URL in the wp-config however. I’d always searched the database to change this. Nice post

  3. It will be quite easy with rsync if used LAMP maybe just a few seconds

  4. 1) Install free “Duplicator” plugin from directory to create zip of your WordPress site.
    2) Install free DesktopServer Limited for your platform (Mac or Windows)
    3) Drag the zip to the “blueprints” folder and run DesktopServer to create a site based on the “blueprint”

    BAM! Now you’ve got your website on localhost instantly without having to drop a dime. View backups, create copies, test out new plugins, themes, all safely without mucking up your SEO, it even remaps all your paths and folders for you INSTANTLY.

  5. How to upload wordpress from localhost to online server. It’s very important to know every WordPress Developer. This is a very helpful article.

  6. It’s not my first time to visit this web site, i am browsing this site dailly and get pleasant information from here everyday.

  7. Thanks for this great step-by-step tutorial. I had this problem and my eyes had turned red when I saw this article. Now I am smiling.

    Thanks.

  8. Thank you bro, it was the best thing ever happened to me. I spoiled a whole day on this and then you came up like a blessing. Thank you so much for this wonderful post, keep doing the same. Wish you all the best in life ahead.

  9. Man..thanks a lot..sweet and smooth transition!

  10. Hello Dear, are you in fact visiting this site regularly, if so then you will without doubt obtain good knowledge.

  11. This is great! First time working on WordPress locally and wanted to transfer my work! Other sites had complicated steps. This was easy and I didn’t know that I could define the site and home in wp-config.php. So cool thanks a bunch!

  • Comments are Closed

Search

Our Sponsors