December 30, 2014 | Posted in SQL Tips | By

To move a WordPress web site from one web hosting company to another sometimes can be very stressful due to the unknowns on how WordPress has been saved at the older location.

The following step by step will provide you with the best method to verify your work and keep maintenance limited. The following was done using a Windows 7 machine and extracting a web site from a Linux web server as well as moving it back to a Linux web server.

1. Getting the files from the web hosting machine.

You will need an FTP account to download the entire web site to your local machine. A great software tool to use is FileZilla which is free and can be downloaded from http://www.download.com. All you need is the client version and a few clicks will enable the software you have run the setup.

You will need to get the FTP address from the older web firm as well as the username / password to successfully log into your account.

Once you start up FileZilla, you will have to create a new site (the old web server), on the left window will be the local machine at your location and on the right side will be the remote machine which is the old web server.

A. Create a separate folder on your workstation to safe store the next few steps listed below.

B. You need to download the following folders (wp-admin / wp-content / wp-includes – default directory names), you may run into a installation where the wp-admin was changed for security but that is something you should know unless you had a private installer do it without informing you. That is a Blog on it’s own.

C. Download the files that are in the root directory above these folders, some names are wp-config.php / wp-login.php / wp-settings.php, if you see those files you are doing well. There should be roughly 16 files as you can see below.

The entire process can take between 20 to 30 minutes to download depending on MP3, images, junk.

 

FileZilla

1A. Putting the files on to the new web hosting.

Once you successfully download from the OLD web hosting firm, now you can upload them to the new web hosting firm by creating a new site under file / site manager using filezilla.  You will have locate the NEW FTP IP Address as well as the username / password.

Remember you have to recopy the files / wp-content / wp-admin / wp-includes all up to the NEW web hosting folder which can be either under “www” or “public_html”, this all depends on your web hosting.

2. Backing up the database.

Most folks are using Linux on their web server along with a tool called PhpMyAdmin. You will need to log into your web server account and check the control panel for this tool. PhpMyAdmin makes the task of managing your MySQL databases easier and more efficient, and it allows you to manage those available databases from anywhere and provides you with various different options. The one we are looking at is the export feature and once again provides you with these formats:

SQL
CVS
CodeGen
CVS for Microsoft Excel
Microsoft Word 2000
JSON
LaTeX
MediaWiki Table
OpenDocument Spreadsheet
OpenDocument Text
PDF
PHP Array
Texy! Text
YAML

For the most part you will either use SQL or CVS for exporting purposes.  Remember this is a web based tool, so if you hit the back button or shut out the browser you lose connection. So be careful.

Exporting databases

A. Log into phpMyAdmin
B. Log into your cPanel and click the phpMyAdmin icon under the Databases heading, you may not have that and instead need to click on MYSQL to access the PHPMYADMIN
C. Start up PHPMYADMIN and click on the database you will be working with.
D. Click Export in the top menu
E. Under the Export heading, ensure that all of your tables are selected and that the SQL option is selected.
F. Keep all the options that are default.
G. Ensure the Save as file option (towards bottom of page) is checked. You will see _SERVER_, you should change it to WORDPRESSMMDDYYYY to have a date stamp on the file.
H. Click Go
I. You will be prompted to either open or save the file. Please select the option to save the file and then save the file into the working folder that you are using for the web site.

phpmyadmin

3: Create The WordPress Database On Your New Host Server

Log in to your new web host with the user credentials they have supplied you and connect to the cPanel software. Most of the firms are using MYSQL for the database manager. If your web host doesn’t have that application running then you will should contact their support team to discover their method of creating new databases.

Simply do the following:

A. Open MySQL Database and create a new database with an appropriate name for your website.
B. Create a new MySQL user (with a secure password).
C. Add this user account to the new database and grant it All Privileges.

Write all of this information down because you will need it.

Click on phpMyAdmin / import, browse and locate the CSV or SQL that you exported earlier and click Go.  If everything successfully is imported you will see the tables created in the new database.  I know that this sounds way too simple but it really is.

4: You will have to Edit the wp-config.php file on your local workstation

Locate the wp-config.php in the backed up folder you created back in step 1. You can use any simple text editor to make the modifications.

A. Change The Database Name

Locate the following line:
define('DB_NAME', 'db_name');

The db_name portion of this line will currently be set to the MySQL database name of your old web host. You have to change it, as in our examine it would be WordPress12262014

B. Change the Database Username

Locate the following line:
define('DB_USER', 'db_user');

In this line you need to change the db_user portion to the username that is associated with the database.  Most likely the new username that you created earlier.
C. Change The Database User Password

Finally, edit the third line:
define('DB_PASSWORD', 'db_pass');

As with the others the db_pass section of this line must be changed to the new secure password you created for your MySQL user.

Save wp-config.php and close the file.

5.  Validate the database by testing the new web site based on what your hosting firm provided you.  All web hosting firms have different measures on how to test the new web site.  Keep an eye on wp_options (using phpMyAdmin) for “siteurl” and “home” which will contain the original url.  If you are in test mode and click on the link it will go to the current web site in production.  You may have to change either one to the IP address or the testing url to confirm that the files and database have successfully moved over.

You will have to change them back to the production web url that you are using (example would be www.yahoo.com) to be prepared when you change the IP address in the DNS server to point to the new web hosting firms.

6. If you had any kind of rewrites (permalinks) setup you must disable .htaccess and reconfigure permalinks when it goes live.

7. Finally it is extremely important that you check the wp_options table (phpMyAdmin) for the field fileupload_url this will be the old home directory from the OLD web hosting firm, you will have to put in the latest HOME folder from the NEW web hosting firm into this folder otherwise when you begin to upload any media, those files can be placed into areas you would not have thought of.

8. Final gotchas sometimes are the plugins that you used, they may give you grief on the new hosting company and possibly you will need assistance from them to update the PHP.INI for includes or any other type of modification.

I hope this helps you out when moving a WordPress web site from one company to another, I recently did the similar moves and had success with a few minor glitches of special characters that were embedded in the posts that did not translate correctly when importing back into MySQL.