How to Move WordPress – Essentials tutorial

OK, I should probably qualify the title. This guide should give you all you need to know to be able to move a standard WordPress (i.e. NOT WordPress MU edition)  site from one location to another. What I’m not going to discuss here are the SEO redirects that you will need to do to prevent rank loss, or what you will need to do if you also want to alter your permalink structure at the same time.

Moving WordPress strikes fear into many a web developer, but it doesn’t have to be such a nightmare. There are a few possibilities when you move wordpress:

  • You may be moving the installation path e.g. from to
  • You may be moving to a new domain e.g. from to
  • You may be moving hosts, from one server to another.

Or, if you are a real blog-warrior, you’ll be attempting to do two or more of the above!

Step 1 – Cover your butt!

It should go without saying, but backup everything on the server – your files, and databases. Usually there are facilities provided by your hosting provider that will facilitate this.

Step 2 – Tell WordPress about it’s new home

Unless you are changing the URL of your WordPress site – and this might mean a change to the domain itself and/or a changes to the paths – then skip to Step 3

Log into WordPress as an administrator, and go to Settings > General. Here you will see WordPress address (URL) and Site address (URL).

Change the URLs to suit where you want to move your installation to. If you need an explanation of the difference between the two URLs then read the article in the WordPress Codex on Giving WordPress Its Own Directory.

From this point onwards you will get a page not found error, because WordPress is now expecting to be found in the new location. All we have done at this point is updte a couple of rows in the wp_options database table (namely the rows where option_name=siteurl and option_name=home). If you chicken out at this point, you can get WordPress back again by resetting the above rows of your database to the old values – or restoring the database from the backup you just took (you did take a backup didn’t you?)

Step 3 – Moving the files

I say moving but to be on the safe side, always copy! There isn’t really much to say here. Take your WordPress files, and copy them into their new location! A few catch out’s here though…

If your destination Site address and WordPress address differ, then again, read the Giving WordPress Its Own Directory article to ensure you move all of the files required into the correct place.

Step 4 – Moving the database

If you are just moving WordPress between paths on the same server, then you won’t need to move the database – just update it, so skip to step 5.

There are a few options when it comes to moving your database. WordPress has a nice guide to Backing Up Your Database – but here is the overview.

Using a graphical user interface

You can either use tools provided by your hosting provider (usually phpMyAdmin) to download a full backup of your database.  If you are moving between cPanel or directAdmin servers then you can probably also get away with the control panel built in MySQL backup and restore facilities to move the database. It should be quite straightforward, unless your database is massive, in which case…

Using the linux shell (SSH) to dump MySQL

Dump might sound destructive, but it really just means take a copy. Depending on the version of MySQL installed on your old host you can try running this from the command line:

mysqldump --opt -u username -ppassword databasename > blogbackup.sql

Or if you want to create a compressed file (quicker download!)

mysqldump --opt -u mysqlusername -pmysqlpassword databasename | gzip > blogbackup.sql.gz

The –opt switch adds a raft of switches to the mysqldump command, ensuring that the dump includes instructions to completely replace the contents of any tables that already exist on the new server’s database.

Create the database on the new server

I’m going to assume you are using cPanel, DirectAdmin or something similar – in which case, you should create the new database using the control panel tools available. Your user account probably won’t have the rights to create a new database anyway, and doing things outside the framework of your hosting control panel will probably break things.

Just create the new empty database.

Uploading the database to the new host

If you downloaded a database export using your control panel software, then restoring it should be just as simple. Likewise, if you used phpMyAdmin to backup your database, then just use phpMyAdmin on the new host to re-upload and import the MySQL archive you created earlier.

Depending on the size of the archive file on your local machine, you might encounter problems re-uploading it. If this is the case you will just have to figure out a way of moving it from one server to the other – maybe your new hosting provider can help (any good one should do!)

If you are importing your database from the command line don’t forget, if you compressed the backup file, you will need to extract it first with gunzip so that mysql can read it. Then, to import the dump file back into MySQL use:

mysql -u mysqlusername -pmysqlpassword databasename < blogbackup.sql

Obviously, replacing your mysqlusername and mysqlpassword and databasename as necessary.

This should load up your data, deleting any existing tables if they already exist – so now your new site should work!


If you have moved host, then it is likely that your new database, mysql username and mysql password have changed. So, don’t forget to update the connection details in the wp-config.php file once you are ready to go!


If you have just moved hosts, but the URLs of your installation have remained unchanged, then you don’t need to worry about this section. However, if they have, then read on.

What I’m not covering here is a change in your permalink structure. That is a topic for another day, but there are plenty of WordPress plugins to assist in this task.

All of the links between your pages, in your menu, and in the various options within wordpress that might been been created by your theme will all be referring to URLs in your old domain and path structure. So for example, your old site had a page at:

and the new location for this becomes

then after going through the whole move process above, you are going to find your database full of references to the old URL.This is usually because you have been developing a site on a development URL and now you want to publish on a production URL.

There are generally two ways to deal with this.

  • do a mass search and replace on the mysql dump file created above, before uploading it to the new server – the techniques for doing this are broad and varied, and I’ll leave it up to the readers imagination to complete this task.
  • so a search and replace throughout the database tables in-situ either on the old server immediately prior to dumping mysql, or the new server after inporting the database.

To do the search and replace using MySQL in situ, then you need to find and replace within a few tables. The following MySQL commands will normally cover the changes yo will need, but depending on your theme/framework you may find the old domain/path cropping up in other places.

51&q=UPDATE&lr=lang_en">UPDATE wp_options 51&q=SET&lr=lang_en">SET option_value=(5.1/en/string-functions.html">replace(option_value,'',''));
51&q=UPDATE&lr=lang_en">UPDATE wp_postmeta 51&q=SET&lr=lang_en">SET meta_value=(5.1/en/string-functions.html">replace(meta_value,'',''));
51&q=UPDATE&lr=lang_en">UPDATE wp_posts 51&q=SET&lr=lang_en">SET post_content=(5.1/en/string-functions.html">replace(post_content,'','')), guid=(5.1/en/string-functions.html">replace(guid,'',''));


The above should provide a good grounding in what is required to move WordPress around in one article.

It assumes you know the basics of linux file management and MySQL, but I hope it helps anyone who is trying to move their WordPress site!




No comments yet.

Leave a Reply

Bot test * Time limit is exhausted. Please reload the CAPTCHA.