HowTo: Move WordPress/MySQL from a local server to a GoDaddy hosted environment

November 15th, 2011 by Paul Sterley | Filed under Hosting, Migration.

I just moved a couple of blogs from a local server to a GoDaddy hosted environment. Here are the steps I went through.

First, find out what version of WordPress GoDaddy’s hosting center is currently using. Upgrade your local blog to that version before you start, and verify that your plug-ins work. Update the plug-ins if necessary before you move the blog.

When you’re ready to move it, the first thing to do is back up your MySQL database. Use something like MySQL Administrator to back it up to a .sql file.

Log into your GoDaddy environment and use the hosting center to install a WordPress application with MySQL database. Open your new hosted WordPress blog (empty at this point) to make sure it works. Then proceed.

Now it’s time to import your MySQL database. But first we have a choice to make:

Do you want direct access to manage your database using your own admin tools, or are you content with the web-based one GoDaddy provides?
Is your database VERY LARGE? So large that it would be exceeding difficult for you to edit the .sql file with a text editor?

If you answered NO to both of these questions, use “Option A: Edit your .sql file to reflect the new database name.”
If you answered YES to either of these questions, skip down to “Option B: Create the database and reconnect WordPress to the new one”.

Option A: Edit your .sql file to reflect the new database name:

The next step is to import your .sql backup file into the new GoDaddy MySQL database. But first you have to edit the .sql file and change the database name in three places, to match the database name the GoDaddy created for you.

You’re looking for three lines near the top of your SQL file. They start with “Create schema”, “CREATE DATABASE IF NOT EXISTS”, and “USE”.
Replace the database name on each of these lines with the one that GoDaddy created.

Option B: Create the database and reconnect WordPress to the new one
Note: Skip this section if you chose to use Option A.

Go to the DATABASES section of the hosting center, and choose to create a new database.
Note: The dialog for database creation has two very important features.
1. A radio button that allows you to choose whether your database will be externally directly accessible or not (see image below.)

 

2. The ability to choose the name of your database, instead of the random name that the WordPress installer chooses. The database name will be the same as the user name. The dialog does not make this clear, so when it asks for a username, that’s where you put the database name.

If your database is very large, and it would be difficult to edit the .sql file, you can create the new database using the same database name as it had on the local server. Then you do not need to edit the .sql file.

Now that you have created a fresh database, use either your local admin tools, or the web-based tools that GoDaddy provides, to import the .sql file into your new database.

Delete the database that GoDaddy created while installing WordPress.

Now that you have your database populated, edit your wp-config.php file to point at it.
To do this, fire up an FTP client and point it at your new hosted environment.

The wp-config.php file is in the folder where you installed WordPress. This might be the root folder, or it might not, if you chose to install it into a folder. Find your WordPress installation, and find your wp-admin.php file. Download it to your workstation for editing.

When editing the wp-admin.php file, be careful. I used Notepad.exe built into Windows, and it corrupted the file. It took several tries before I figured out what was happening. You might want to try another text editor, or an HTML editor. make backup copies, and when you’ve saved the file, open it again to verify that it didn’t get scrambled.

In the wp-config.php file, you’re looking for your database name. It should exist in three places: DN_NAME, DB_USER, and DB_HOST. GoDaddy creates the username the same as the database name. Edit this file to point at the correct database, and upload it back to your WordPress folder.

Upload your WordPress content.

I recommend that you create a “new blog backup” folder on your admin workstation, and use your FTP software to download the empty WordPress installation to your admin station, so that if something goes wrong with uploading the content, you can put the old files back in, or at least fish files out of that backup folder if you are troubleshooting. Since the new installation has no content, it will only take a few seconds to make a backup of it, and it might save you a lot of time.

Use your FTP software to upload your wp-content folder from your local installation. I believe that you do not want to upload any other folders – just wp-content and all of its subfolders. My suggestion is to NOT overwrite any files.

That being said, I had some difficulty with my migration at this point, and what I ended up doing was creating the folder first, uploading my content into it, and THEN installing WordPress using the GoDaddy wizard. I am not sure this was necessary. It may be that my fumbling around with which folders to upload created my problem.

Now you’re ready to try out your blog! If all went well, it should work as expected at this point.

Good luck!

 

Share Your Thoughts