How To: Move WordPress from Localhost to a Server using phpMyAdmin

Published on January 11th, 2013

Last Updated on March 16th, 2021

Tags:

Share This Article

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:
https://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.

Article Continues Below

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

Article Continues Below

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 https://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 https://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');

Article Continues Below

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

/** Defining WP_HOME and WP_SITEURL */
define('WP_HOME', 'https://yoursitename.com/');
define('WP_SITEURL', 'https://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 https://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!

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.