How to Move a WordPress Site

Posted by on May 1, 2012 in WordPress Development | 66 comments

How to Move a WordPress Site

9/7/2012: I’ve started receiving messages from people experiencing problems moving their WordPress installations. There seem to be some new issue specific to WordPress versions 3.4.1 and up. I’ve conducted a quick experiment with one of my sites and am definitely experiencing issues with the widgets.

(0834) The widget issue is specific to the widget overrides in my RocketTheme theme. Otherwise, things are running smoothly. If you’re having difficulties, please get in touch me via the contact form and be specific about the issue you’re experiencing. As always, I’ll do my best to work with you.

I’ve had the good fortune of needing to move a WordPress installation so often that I’m discovering it to be nearly second nature. It’s not a difficult process, but it’s not intuitive either. Still, things will crop up during the process of moving WordPress from one hosting provider to another, or migrating a WordPress installation from my development environment to a production server. This tutorial will attempt to hit the high points.

Background

The first time I tried to migrate a WordPress site by brute force I made a royal hash of it. I’ve learned over the course of a number of WordPress moves that there’s a knack to doing it quickly and effectively. At this point I can transfer WordPress from one server to another, change the domain WordPress was installed under, fix the inevitable broken images in the posts, and have the site fully functional within a few hours – most of which is time spent copying files.

Before undertaking this endeavor, you should make sure that your new hosting arrangements are in place. Create an empty database at that location if necessary, and ensure that you have FTP access to the site’s final destination. For the sake of this tutorial I’m going to assume that you understand what this means and how to go about achieving it – if not, you should start by investigating your new hosting provider’s documentation in order to get up to speed.

If you are going to use Yahoo Small Business Web Hosting

Check out the post I wrote about Moving WordPress and Yahoo Small Business Hosting. I’ve had to do a few migrations of WordPress sites to or within Yahoo Small Business Web Hosting, and their administrative controls are so restrictive that it can turn into a total nightmare. Forewarned is forearmed.

WordPress Installation Migration Tutorial

Step 1: Make a Local Copy of the Existing WordPress Site Files

The first thing I do is connect to the FTP server which provides access to the files for the existing WordPress installation. In the case of a site I’ve developed locally and need to deploy I obviously have all the files already. Getting an entire site is time consuming and, with any decent FTP client, it’s automated, so I make this step one. Just connect via FTP and sync a directory on your local disk to the document root which contains your live WordPress install. Now, with files a-transferrin’, we can move on to other steps.


Step 2: Get a Dump of Your Current WordPress Database

The easiest tool to use here is going to be phpMyAdmin. Any hosting provider worth their salt is going to offer this to their users. Follow these steps to get your existing database exported:

  1. Connect to the instance of phpMyAdmin which provides access to the database for your current site. Enter your credentials to log in to the management interface.
  2. Select the database for your existing WordPress installation from the list on the left.
    Select your WordPress database from phpMyAdmin's list of databases.

    (Fig. 1) Select your WordPress database from phpMyAdmin's list of databases

  3. Click ‘Export’ at the top of the window.
    Click 'Export' at the top of the window.

    (Fig. 2) Click the 'Export' tab at the top.

  4. Ensure that the radio button for the ‘Quick’ export method is selected. Click the ‘Go’ button to download a .sql file containing a dump of your current database table structure along with all of your existing data.
    Check the 'Quick' export method radio button and click 'Go' to download your database dump.

    (Fig. 3) Check the 'Quick' export method radio button and click 'Go' to download your database dump.


Step 3: Import Your Database

Now you have to reverse the export process to populate your new database.

  1. Log in to the phpMyAdmin interface for the new database.
  2. Select the new database from the list on the left (see Fig. 1, above).
  3. This time, click the ‘Import’ tab at the top of the window.
  4. Now you’ll have to select the file you just downloaded containing your database dump so that you can upload it here. Click the ‘Choose File’ button and locate the .sql file downloaded during Step 2, above.
    Click the 'Choose File' button and locate the .sql file you just downloaded.

    (Fig. 4) Click the 'Choose File' button and locate the .sql file you just downloaded.

  5. All that’s left for this step is to click the ‘Go’ button to import your data.

Step 4: Apply Database Migration Fixes

There are two primary fields which need to be modified in order for your migrated WordPress installation to even function.

  1. Rather than browsing the data in the wp_options table, let’s just click the ‘SQL’ tab up at the top and send the Database Server Ninja Assassin Monkey Troop off to do our dirty work:
    1. UPDATE wp_options SET option_value = 'http://www.craniumstorm.com' WHERE option_name IN ('siteurl', 'home')
    UPDATE wp_options SET option_value = 'http://www.craniumstorm.com' WHERE option_name IN ('siteurl', 'home')

    Insert that SQL query in the giant ‘Run SQL query/queries on database…’ field and change the http://www.craniumstorm.com to reflect the root level of the site you’re transferring to (so, if you’re moving WordPress to www.domainfoo.com/bar make sure that the /bar is appended here).

    Click 'SQL' at the top and paste the SQL query, above, into the appropriate field.

    (Fig. 5) First, click the 'SQL' tab at the top. Then, copy-paste the above SQL query into the appropriate field and modify it to reflect your new domain before clicking 'Go'.

  2. Click ‘Go’ to execute the query. You should see a green message box saying that two rows were changed.
  3. UPDATED: Things change, and I’d be remiss if I failed to update my most popular tutorial to reflect my present methods. At this point, you’re ready to update your image URLs. Do yourself a favor, save yourself some time, and use the Velvet Blues Update URLs Plugin, available from the WordPress Plugin Directory. This plugin is so handy, and works so smoothly, that it should be incorporated into the WordPress core. I can’t imagine why you’d want to perform this step by hand, but if you’ve got a hankering for some more SQL-executin’ action, read on…

    If you’ve read some of my other stuff, you may have seen the post about fixing broken image links in WordPress posts when transferring domains. I’ll re-iterate it here to spare you having to read any more of my torturous bullshit. Now that our crack team of Database Server Ninja Assassin Monkeys has returned from their recent, successful foray, we’ve got another mission to which they’re ideally suited:

    1. UPDATE wp_posts SET post_content=(REPLACE (post_content, '{old url}','{new url}'))
    UPDATE wp_posts SET post_content=(REPLACE (post_content, '{old url}','{new url}'))

    You’re already right where you need to be. Just paste this query over the last and modify the {old url} and {new url} to reflect whatever constitutes reality in your case and then click ‘Go’ again.

    (Note: When I say ‘modify them to reflect reality’ I mean that you’ll want them to be the full significant portion of the url which needs changed. So, if you’re moving from http://www.oldfoo.com/blog to http://www.newfoo.com you’ll want {old url} to say ‘www.oldfoo.com/blog’ and {new url} to say ‘www.newfoo.com’.)

  4. Smile. You’re getting good at this.

Caveats

If you’re moving your WordPress install to the directory ‘/bar’, but you want visitors to get to it by going to ‘http://www.domainfoo.com’ (without the ‘/bar’), step 4.1 is going to be different for you. In such a case you need different values for ‘home’ and ‘siteurl’. From the WordPress Codex entry Changing the Site URL:

  • The “Home” setting is the address you want people to type in their browser to reach your WordPress blog.
  • The “Site URL” setting is the address where your WordPress core files reside.

This means that we’ve got to run two queries in the first step instead of one. The code you’re going to paste is going to look like:

  1. UPDATE wp_options SET option_value = 'http://www.domainfoo.com' WHERE option_name = 'home';
  2. UPDATE wp_options SET option_value = 'http://www.domainfoo.com/bar' WHERE option_name = 'siteurl'
UPDATE wp_options SET option_value = 'http://www.domainfoo.com' WHERE option_name = 'home';
UPDATE wp_options SET option_value = 'http://www.domainfoo.com/bar' WHERE option_name = 'siteurl'


‘You do not have sufficient permissions to access this page’

This will happen if you change the wp_ prefix on your WordPress database tables. Everything’s just starting to come together for you, but when you try to access your admin panels you get a box in the middle of the screen saying ‘You do not have sufficient permissions to access this page’. The WordPress Codex entry for Login Trouble has a bunch of things to try, but none of them apply to the issue you’re having. I’ll include the correct fix here:

  1. UPDATE `{new prefix}_usermeta` SET `meta_key` = REPLACE( `meta_key` , '{old prefix}_', '{new prefix}_' ); UPDATE `{new prefix}_options` SET `option_name` = '{new prefix}_user_roles' WHERE `option_name` = '{old prefix}_user_roles';
UPDATE `{new prefix}_usermeta` SET `meta_key` = REPLACE( `meta_key` , '{old prefix}_', '{new prefix}_' ); UPDATE `{new prefix}_options` SET `option_name` = '{new prefix}_user_roles' WHERE `option_name` = '{old prefix}_user_roles';

Just replace {new prefix} and {old prefix} in the above query with the correct values for your situation. (Special thanks to Christian Schenk for his great write-up on this issue!)


Step 5: Upload the WordPress Site and Edit Your Configuration

If your files are still downloading at this point just make a cup of tea and relax for a while. Uploading the entire WordPress site is the next logical step here.

  1. When you’re ready, connect to the FTP host for the new site.
  2. Upload the entire contents of the site to its new home.
  3. Edit your /wp-config.php file to include the correct information for your new database:
    1. // ** MySQL settings - You can get this info from your web host ** //
    2. /** The name of the database for WordPress */
    3. define('DB_NAME', 'craniumstorm');
    4.  
    5. /** MySQL database username */
    6. define('DB_USER', 'craniumlocal');
    7.  
    8. /** MySQL database password */
    9. define('DB_PASSWORD', 'somePass');
    10.  
    11. /** MySQL hostname */
    12. define('DB_HOST', 'localhost');
    13.  
    // ** MySQL settings - You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define('DB_NAME', 'craniumstorm');
    
    /** MySQL database username */
    define('DB_USER', 'craniumlocal');
    
    /** MySQL database password */
    define('DB_PASSWORD', 'somePass');
    
    /** MySQL hostname */
    define('DB_HOST', 'localhost');
      
  4. This has come up a couple of times now, so I’m going to say here in advance that you should try logging into the admin panel in the new location at this point. If you get in without any problems, go to Settings > Permalinks and click ‘Update Permalinks’ to make sure WordPress updates the .htaccess file. If it can’t for some reason, you should see a message reading something along the lines of ‘If your .htaccess file were writable, we could do this automatically, but it isn’t…‘ at the bottom of the admin panel. In that case, make sure that you edit your .htaccess file to reflect your current domain configuration:
    1. # BEGIN WordPress
    2. <ifmodule mod_rewrite.c>
    3. RewriteEngine On
    4. # RewriteBase must reflect the root of your WordPress installation
    5. # So, if you're running WordPress at http://www.domainfoo.com/bar
    6. # you'll need to set this to 'RewriteBase /bar'
    7. RewriteBase /
    8. RewriteRule ^index\.php$ - [L]
    9. RewriteCond %{REQUEST_FILENAME} !-f
    10. RewriteCond %{REQUEST_FILENAME} !-d
    11. RewriteRule . /index.php [L]
    12. </ifmodule>
    13. # END WordPress
    14.  
    # BEGIN WordPress
    <ifmodule mod_rewrite.c>
    RewriteEngine On
    # RewriteBase must reflect the root of your WordPress installation
    # So, if you're running WordPress at http://www.domainfoo.com/bar
    # you'll need to set this to 'RewriteBase /bar'
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </ifmodule>
    # END WordPress
      

    If WordPress is unable to modify this file automatically it’s because of a permissions problem. The best means for fixing this depends on your hosting provider, but the .htaccess file needs to be writable by WordPress.

  5. That’s about it!

Aftermath

Naturally, you’re going to want to verify that your site is working correctly before moving on with life. The only variables we didn’t address here are plugins and templates. The primary offenders I’ve found are plugin authors who have elected to store literal URLs for files in the Media Library instead of using get_bloginfo(‘wpurl’) for the URL base (if you’re such a plugin author, fix your code please).

Stay Tuned…

If you enjoyed this post or found it otherwise useful, please support CraniumStorm by liking us on Facebook. We’re looking a little shabby over there, and if 1/10 of the people who came to this site just to view this page turned out in our support, we’d have 50 likes already this month!

49 comments
helz123
helz123

I can't thank you enough for this article - it saved a lot of time when things were getting a bit "ranty"! It's going on the blog now everything's working properly. Thanks again!

jrmb23
jrmb23

You saved me a TREMENDOUS amount of work.  I had been trying to do this for days and days and your site guided me perfectly through it.  THANK YOU SO SO MUCH!!!

Jean Francois Garcia
Jean Francois Garcia

thanks for this tutorial.

I have move my site to an other server, all seems good, but I can't access to the admin panel after login.

The "Red section" if the only one I Haven't done. I apply it and Now, all is ok !


Thank you for this job ! I'll put this page in my favorite, for a future problem ^^

stevedovey
stevedovey

Thanks sooo much, you just saved me hours of work and a mountain of stress!!! I was dreading this as I've had a couple of WP moves bomb on me badly. This went so smoothly. About the only that didn't go 100% according to plan was a few image referrals but those shouldn't be hard to fix.

This comment has been deleted

JakeHarris
JakeHarris

I ended up doing it the old fashioned way: running a ctrl+h on the .sql file. In my particular case, it looked like this:

Replace: old.development-server.com

With: newdomain.com

Good luck :)

Qwaerstd
Qwaerstd

Hi 

Thanks for your post. I've used this technique before with success but this time I cannot seem to get the image links to update. 

I've used UPDATE wp_posts SET post_content=(REPLACE (post_content, '{old url}','{new url}')) and tried the old and new urls both with and without http://www.,trailing slashes and wp-content/ at the end but nothing seems to make a difference. I've also tried logging out of WordPress and back in, and have been through the whole process twice.

Does anyone have any suggestions? Thanks

rananjason
rananjason

Hi. I, actually, reinstall my website after defacing attack. I decided to change 'SITEURL="www.domainname.com/secret_folder"' to point to a different folder.

The problem is on the dashboard, I don't see my older posts and pages otherwise on phpmyadmin, I can see all of my publication.

Can you help me howto fix this?

rananjason
rananjason

Finally, I retrieve the problem. I omit the right table prefix o wordpress, so the new destination installed a new database!

golena
golena like.author.displayName 1 Like

I was terrified of moving my wordpress site to the new domain (and new hosting).  Your tutorial was perfect and everything transferred beautifully. Just had a few image links that had to be updated on the new  site.    Thank you, thank you!!

mamta108
mamta108

Thanks for this.  I'm having a problem still, though.  When I try to loginto my account live on godaddy (name of site.com) it routes me back to my log in for my virtual hosting site desktop server (name of site.dev).  There must be some file that I can change this simple script for...  I thought it was mysql file, but that is all correct.  Any help would be greatly appreciated.

jonahs
jonahs moderator

 @mamta108 On its face, I'd say that this sounds like a home URL/ site URL issue as described in step 4.1, above. However, assuming that you've completed that step successfully, I'd suspect that there's a redirect occurring in either your index.php or .htaccess file. Please use the contact form to reach me if you're still not having any luck.

merk
merk

Hi, thank you for a great post. it seem very simple, I just wonder what will be the steps if one wish to test the new site before changing the DNS..

jonahs
jonahs moderator

 @merk I'm afraid that I may not be understanding you. Do you want to test the DNS changes before actually moving the site?

This comment has been deleted

This comment has been deleted

This comment has been deleted

DodgeIntheshed
DodgeIntheshed

Thanks for that  jonahs,Apart from the slight problem with the DB (see below), it worked a treat.

Dodge.

DodgeIntheshed
DodgeIntheshed

Hi jonahs,When I try to import my database, Im getting this error:

SQL query:

-- -- Database: `echographicsonl` -- CREATE DATABASE `echographicsonl` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;

MySQL said:

#1044 - Access denied for user 'echoadmin'@'localhost' to database 'echographicsonl'Can you help?Thanks, Dodge.

 

DodgeIntheshed
DodgeIntheshed like.author.displayName 1 Like

Sorry jonas,My mistake,I had to go back to the old database and change the Character Set to utf8!!!

daniel_dropik
daniel_dropik

Thank you, this may help. Can the process described above work when I am trying to move my WordPress website onto my local workstation( which I will be using for testing the site "offline") ?

jonahs
jonahs moderator

 @daniel_dropik Absolutely, Daniel. In essence, anywhere I would have 'www.craniumstorm.com', I would want to replace it with 'localhost'. Use the contact form to reach me if this is confusing, or if the process goes south on you!

BrianWhitton
BrianWhitton like.author.displayName 1 Like

Thanks. Great tutorial. I was reading WP's tutorital but got a bit confused as to when to edit databases and such.

 

I didn't need the old blog to work, so before I exported the database from my original server, I used the safe search and replace script at this site: http://interconnectit.com/124/search-and-replace-for-wordpress-databases/.

 

It updated all instances of www.devserver.com/client to www.clientsite.com and fixed it for serialization issues.

 

Then I was able to skip step 4. Very handy!

BtrBetaTrading
BtrBetaTrading like.author.displayName 1 Like

Awesome tutorial! Aside from a minor user error on my part, it worked flawlessly. Thanks so much for sharing the knowledge.

Jan Bear
Jan Bear like.author.displayName 1 Like

You saved my life with this tutorial. Thank you.

sarahbbrand
sarahbbrand like.author.displayName 1 Like

You are a hero of the internet. One thing I might add is that if someone does this and is getting "500 Internal Server Error" messages at all, manually checking the .htaccess file is useful even if Wordpress was able to update the permalinks automatically... for me, Wordpress just appended a second set of rewrite rules to the bottom of the .htaccess file, so the rules referencing the old site were still there.

jonahs
jonahs moderator

 @sarahbbrand If I have seen further, it is by standing on the shoulders of giants. Still, thank you kindly. Also, thank you for sharing your experience. A couple thousand people a month are now coming to read this article, and you've certainly helped some of them.

tempestuality
tempestuality

Great tutorial! Thanks for writing it :) I am installing an extension for Magento to integrate it with WordPress (FishPig WordPress Integration). So far that is going well. However, it states that:

                        It is recommended that you install WordPress in a sub-directory of Magento. Do not install it in a sub-                             directory that you plan to make your blog visible on.

My Magento install is on my root directory, and WP is in a subdirectory, and in violation of the above since it is installed in the directory it is visible on. So I made /wp for it and need to move it there but still show it at /blog. I followed directions on the codex for giving wp it's own subdirectory: 1) make subdir 2) wp-admin/ general set site url to the /wp and home kept same for /blog (full url entered) 3) moved all files from /blog to /wp, 4) copied back over the index.php and .htaccess 5) edit /blog/index.php entry to require('./wp/wp-blog-header.php'); (was without a subdir originally), was able to sign in, but here is where I am stuck, got sign in, but then got errors. Basically it is looking for header file in blog/wp/. So I tried going from the entire file structure /home/my username/my site/wp/wp-header, and no. Tried without the / in front of home and no, it is still rendering that inside of /blog. I am unable to find out how to make it go up one directory, or change directory to /wp. In the example since it is coming from the root to a subdirectory in the root (blog is shown on example.com, db located at example.com/wordpress) I think that is why that example works. I am having difficulty in finding any answers on moving from subdirectory to another subdirectory. I will search more and if I find a solution, I will reply so you know.

 

Oh, and since I am just changing from one subdirectory to another do I need to make the sql entries above and/or update the Permalinks?

 

Thanks, 

Kelly

jonahs
jonahs moderator

 @tempestuality you answered at least part of your question at step five: './wp/wp-blog-header.php'that leading period tells the server that the '/wp' directory it's looking for is a subdirectory of whatever directory it's currently working in. therefore: if the file is /blog/index.php, a reference to ./<anything> from a file within that directory will use /blog as its base. getting rid of that period will make it '/wp' where '/' is the document root =)now, as to whether you need to run the sql above... if you've moved an existing wordpress installation to any url other than the one at which it was originally installed the answer is yes. make the change above and give it a shot. use the contact form to get in touch if you're still having issues. 

chrisalltogether
chrisalltogether

Is there anything different that needs to be done if i am moving from Wordpress MU to Wordpress 3 MultiSite?  I just want to move some MU sites to another Server running WP3 Muliti site for staging so i can then move to a WP3 Multi for production live.  So I dont need to export the whole database just the wp_# that relates to each site.  I moved them and did a find replace for wp_oldID to wp_newID  and then imported the tables into the MultiSite DB.  The only issue i currently have is lots of images are still pointing to the orignal www.site.com instead of the new stage-www.site.com that it should now be.  It seems the majority point to the new but there are many that do not.  Any Ideas?

jonahs
jonahs moderator

 @chrisalltogether depending on what sort of images you're dealing with, there are a number of places they might reside. if broken images is the only issue you're experiencing as the result of your process i would recommend getting a copy of notepad+ and running a search and replace for your old domain on the SQL dump you're creating.this naturally assumes that you need no further references to the old domain in your new configuration.

This comment has been deleted

MarkMackinnon
MarkMackinnon like.author.displayName 1 Like

Really, really useful post. You've just made moving a WordPress site VERY easy for me.

 

Thank you!

SarahWebDesign
SarahWebDesign

This tutorial works great! The only question is, is there a SQL query like in step 4.3 that would update text widgets and the header and footer images that are used in twenty eleven?

jonahs
jonahs moderator

 @SarahWebDesign different themes, plugins, and widgets will often leverage the wp_options table to store their data. this is because anyone using the wordpress api to extend wordpress can easily stash information there using generic api option storage and retrieval methods.

 

you definitely want to be careful making changes here, because many of the entries in wp_options are highly necessary to wp's proper operation. i would suggest manually browsing the wp_options table in phpmyadmin to see if it can yield any clues.

This comment has been deleted

This comment has been deleted

This comment has been deleted

This comment has been deleted

This comment has been deleted

This comment has been deleted

JoeBrodnax
JoeBrodnax

Since I'm using this page to create a sandbox of a client's wordpress site and it works great!!! I thought I'd just see if you maybe had an idea.

The client tried to move the site himself and did okay until he saw he had ended up with umlauts throughout all his posts. So I went in and fixed his char problems for him, but he decided to continue to post dozens of posts in the meantime.

Is there a way to import everything before a certain date, like May 15th, while leaving everything else intact? Without dropping tables and starting over?

jonahs
jonahs moderator

 @JoeBrodnax 

Hi,

 

You could put the results of the type of queries you're talking about into a pair of ad hoc tables by using syntax like this:

 

CREATE TABLE posts_temp SELECT * FROM wp_posts WHERE wp_posts.post_date < '5-15-2012';

CREATE TABLE postmeta_temp SELECT * FROM wp_postmeta WHERE post_id IN (SELECT id FROM posts_temp);

 

Use the 'Custom' export method in phpMyAdmin to select only your two temporary tables, and under 'Format-specific Options > Dump table' select the 'data' radio button.

 

Then, do a search and replace on the file to replace 'posts_temp' with 'wp_posts' and 'postmeta_temp' with 'wp_postmeta' before running your phpMyAdmin import operation on the target database.

 

Now, this assumes that there isn't a key violation, meaning that the target database doesn't already have database entries with those same IDs. Here's hoping this helped...

JosephBrodnax
JosephBrodnax

 @jonahs 

Thanks brother, a beautifully elegant solution. Using a third container to swap the contents of two containers.  Thanks!

eToTheManders
eToTheManders

I have a few naive questions, if you would be so kind.

 

In Step 4.3, updating the wp_posts table, I was a little confused by your note.  Should I include the full URI (starting with 'http://...' as in Step 4.1?  Also, I don't want to leave the curly brackets inside that literal string, right?  I don't think I want the SQL command to actually write them there.  Thanks, just checking

 

In Step 5.4, updating the .htaccess file.  I was just wondering if you could speak a little bit more about this step.  What does this file do?  I found it, empty save for '# BEGIN WordPress' and '# END WordPress',  but in a higher level directory where a live production site lives (http://liveWPinstall).  I am trying to copy a second Wordpress site into a subdirectory on my hosting server purely for testing purposes (http://liveWPinstall/putTheTestingSiteHere), so I'm thinking that I don't want to modify the .htaccess file I found.  (Curiously, there is no .htaccess file located in my http://liveWPinstall/putTheTestingSiteHere directory.)

 

Thanks very much for your time.

jonahs
jonahs moderator

 @eToTheManders Oh, and no, you don't want to leave the curly braces in! =)

jonahs
jonahs moderator

 @eToTheManders Hi there,At 4.3, what you're doing is akin to a plain old search and replace. I left the 'www' on in the note to try to avoid confusion, but you don't even necessarily need that. The only thing you're truly concerned with searching and replacing is the significant part of the URL that's changing. So, if your old and new URLs are both prefixed with 'http://www.' you can save yourself some keystrokes by not bothering with typing it. It wouldn't hurt anything to type it all out as long as you remembered to put the 'http://' in both strings.

 

Step 5.4 attempts to short-circuit potential problems caused by WordPress not being able to update the .htaccess file on its own. In truth, the majority of users could skip that step by logging into the wp-admin interface, going to Settings > Permalinks, and updating the permalinks. This should cause WordPress to re-generate the .htaccess file with the appropriate settings. In fact, I think I'll update the post accordingly.

GenevieveLaFortune
GenevieveLaFortune like.author.displayName 1 Like

Thank you, thank you, thank you.  I was stressing over this, but you made it easy.  Had trouble editing the .htaccess file, but just let WP regenerate it automatically by resaving the Permalink settings.

amandagilesnh
amandagilesnh like.author.displayName 1 Like

Great tutorial. I needed to move a site locally today and this was super helpful and worked like a charm. Thank you!

kidgroup
kidgroup

Hi there,

I'm using your tutorial to attempt to move my wordpress site but I have a question about step 3. I am unclear what you mean when you say "import your new database."  Does this mean I am creating a new database? or just uploading the dump from the original? Do I need to delete the old one?

 

What I did is just export the old database and then upload the dump but I am getting a 1062 duplicate entry error message (i see it's referencing some images on my site) and it will not allow me to move on. I didn't delete anything or open the dump so it seems like I am just uploading the same database... I'm not familiar with mySQL so I'm unclear on how this works exactly.

jonahs
jonahs moderator

 @kidgroup Hi,I was less explicit that I maybe should have been in writing a couple of these steps. I didn't get into the issues of creating a new database to accommodate the import because every hosting provider does things a bit differently.In essence, what you're doing is creating an empty database in your new database server, selecting that database in phpMyAdmin, and then importing the dump of your original database into it. If you've created a new database with no table structure whatsoever you shouldn't have any problems with duplicate entries.If you have data in your current database which you're trying to simply replace, try this:At step 2.4 select 'Custom'. Scroll down the list of options, check the box next to 'Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT statement'. This will drop your existing tables and re-create them from scratch before adding data.

 

Please let me know if this helps, or if you find another method which works for you and I'll be sure to update my post accordingly.Thanks!

Motosy
Motosy

@jonahs Hi Jonahs, I wish I had found this site earlier!! so what I did was download all my files from the old host. thinkin I could just copy them over to the new host, I never made a dump of the database. Stupid newbie mistake. now, I have a copy of all my files for my site but can't get the database dump because I have cancelled that host. What can I do to get my site to work on the new host? Or am I out of luck and the files are no good to me. Just want to know if I have to start from scratch.

jonahs
jonahs moderator

 @Motosy  unfortunately, if you didn't make a backup of your wordpress database, and your database has been deleted by your previous hosting provider, your site content is gone. if your hosting arrangements were recently discontinued, you may still be able to contact the hosting provider and get a dump of your database. i'd recommend at least trying to contact them to see if they can assist you.

This comment has been deleted

lynos
lynos

Thank you for the nice writing. You make moving a WordPress blog sound simple. Nice visuals too. Thank you for your help moving http://www.peaceengine.com

Trackbacks

  1. [...] For the purpose of setting up a local environment for testing things out, this may not matter. But if you want to update all the links within blog posts as well, instructions can be found in some of the articles linked from here such as this one. [...]