Many WordPress developers find themselves in constant need of moving wordpress installations around. Changing WordPress directories or urls is not as simple as it sounds. Moving WordPress Websites without Plugins is a simple step by step process and I will describe how its done.

There is more work involved that changing a setting in the database and many developers not familiar with the process often fear losing the site completely, which is not an uncommon occurrence. In this post I will provide a detailed and step by step approach on moving the wordpress site or completely backing up a wordpress website.

Ofcourse there are a number of ways you can backup or restore or port existing installations, I am going to describe what I do and what works for me in my experience and this is not the only way to go about it. If this does not benefit anyone else, I will find comfort in the fact that I have a reference for myself. High Five !

First things first, there are two essential pieces to the wordpress website. The first essential piece is the “Database”. WordPress uses MySQL database to store all the page content, posts, settings and configuration and a lot of other important data. The second important component is the theme itself.

I will discuss “Moving WordPress Websites without Plugins” first in detail:

[/one_half_last]

To be able to move a wordpress site, yes you guessed right you need to move the database and the wordpress installation. The first step is to backup the database and create a file that can be restored to another MySQL instance. An easy way to do it is with an application available with your hosting provider. The name of the application is “pHpMyAdmin”. This is basically a tool that lets you run queries against a database available in the hosting environment. The hosting environments differ slightly in terms of the cpanel and the applications interface so I will write down generalized instructions here:

1. Create an Export of the Database using PHPMyAdmin

The only valid question for this step is “Which database should be exported” ? The answer to that is “Simply look at your WP-Config.php file in the installation root directory. It will clearly
tell you the name of the database, the user and password to log on to it. The generic steps are below:

If you have cPanel access to your website:

1. Login to cPanel.
2. There will be an icon for phpMyAdmin in the Databases section. This will take you to phpMyAdmin.
3. The list of available databases will be listed on the left hand side once you get into phpMyAdmin.

Instructions on Exporting a Database

1. Go to an existing database in phpMyAdmin.
2. Click Export at the top.
3. Leave the settings as they are, click the “Save as file” checkbox and click Go.
4. This will download a .sql file to your computer.

Note: You cannot create a new Database using phoMyAdmin and separate utilities are use to do that.

A very nice video that I found on youtube using Host Gator cPanel is here:

Moving the Files Over to the new Hosting:

Let us say for the sake of simplicity that we are moving websites between two urls. The url that we are migrating from is www.oldurl.com and the url where we are migrating to is www.newurl.com. What we need to do is to copy all the files (and directories) that are found in the root directory of the hosting account. An easy way to do this is to use a FTP Client like Filezilla (Free and Open Source) and copy the remote files locally. In this way you will have manual backup as well and then backup everything you have in the hosting root directory of www.newurl.com. Simply Copy the files (all of them) from the root directory of the old hosting to the root directory of the new hosting.

For this step basically you will need the FTP Credentials for both the hosting accounts.

Create a New Database and Import using the export file

First you will need to create a new MySQL Database.Here is a nice video that shows how to create a new database using the cPanel:

Create a MySQL Database:

1. Log into cPanel.
2. Under Databases, click MySQL Databases.
3. In the New Database field, type a name for the database.
4. Click Create Database.
5. Click Go Back.

The new database will appear in the Current Databases table. Create a User for the database as well. Here are the instructions:
Create a Database User

1. Log into cPanel.
2. Under Databases, click MySQL Databases.
3. Click Jump to MySQL Users in the top-right corner of the page.
4. Under Add New User, enter a username.
5. Enter a password in the Password field.
6. For help generating a strong password, click the Generate Password button.
7. Retype the password in the Password (Again) field.
8. Click Create User.

Assign Privileges to Database User

1. Log into cPanel.
2. Under Databases, click MySQL Databases.
3. Under Add User to Database, select a user from the User drop-down menu.
4. From the Database drop-down menu, select the database to which you wish to allow the user access.
5. Click Add.
6. From the MySQL Account Maintenance screen, select the privileges you wish to grant the user, or select ALL PRIVILEGES.
7. Click Make Changes.

Then import the data exported in the previous step. Here are the instructions if you are using cPanel:

1. Go to phpMyAdmin
2. Click the new database name in the top left (optional)
3. Click Import in the main area of phpMyAdmin
4. Browse for the .sql file on your computer and click Go
5. The optional step depends on if the new database name exists. If yes, then go ahead and click it. If no, skip it. If you get an error, refer top the list below.

Here is a nice video tutorial on importing the data:

Update the WP-Config file for database/user credentials

All the Database information, user and connection should be updated in the WP-config file. Here are the samples and make sure to back up the existing file:

// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
define( ‘DB_NAME’, ‘database_name_here’ );

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

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

/** MySQL hostname */
define( ‘DB_HOST’, ‘localhost’ );

Find and Replace all the places in files where old url was referenced

You can use “Notepad ++” or any editor of your liking. Do a Search in the theme directory and rename all occurences of old url with the new url.

Find and Replace all the places in the database where old url was referenced

You can use the awesome script at Database Find And Replace. It comes with instructions on the usage.

Now I am assuming that the files are uploaded to the new hosting account, Database is set up, wp-config is updated !!!

Save your Permalinks again…Seriously !!

Enjoy your site on the new host

Thanks for reading and Cheers !