Add

Migrate Wordpress to a new Server or Directory

If you decide to change the URL or link location of your WordPress Blog due to a new domain or moving to a sub-directory, here are some simple steps that should be done to ensure proper migration without breaking links.

To update WordPress options with the new blog location, use the following SQL command:

UPDATE wp_options SET option_value = replace(option_value, 'http://www.olddomain.com', 'http://www.newdomain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.olddomain.com', 'http://www.newdomain.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.olddomain.com', 'http://www.newdomain.com');

The Discussion

see what everyone is saying

  • Joe Brunno June 2nd, 2009 at 9:17 pm #1

    This worked perfectly! Thank you so much!

  • Lydia July 18th, 2009 at 2:18 am #2

    Really great !
    These three command lines is all you need to have your database running again.

    In all the WP migration advices I found, no ones talks about the fact that, in posts everywhere URLs have to be changed ! Plus don’t try to change it by hand, it will take forever.
    I also tried to dump the tables, open the scripts and find and replace “old url” by “new url”, but somehow there was always something messing up.

    So thanks for these simple 3 sql commands that go a long way…

    Lydia

  • Richard July 19th, 2009 at 8:50 am #3

    @Lydia, Your welcome! I’m happy it helped you!

  • Andy October 20th, 2009 at 4:01 pm #4

    sorry, but where do i have to put these commands?

    thanks for your help

  • Richard October 20th, 2009 at 8:15 pm #5

    @Andy, in your favorite Database Administration tool such as phpMyAdmin.

  • Trevor November 5th, 2009 at 9:03 am #6

    I tried migrating my blog to a new server by copying all directories and the database over. I got the blog running but when I click on an article it give a 404 error. The domain is exactly the same. I just flipped DNS. Are there any database queries that need to be run to make something happen that I’m unaware of?

  • Richard December 6th, 2009 at 4:57 pm #7

    Hey Trevor,

    Nope this works for me.

    Make sure that any other plugins you have installed don’t have a reference to the old URL. Search the whole database.
    Clear your Cache

Respond

get in on the action.

Are you Human?
 

* Required

Random Posts Recent Comments Tags

  • Richard Says:

    @prits, Check your settings for the URL and clear the Magento cache....

  • Richard Says:

    @hucks, That should work....

  • Richard Says:

    @Tony, I believe it is possible. There is only 1 way to find out and that's to give it a try. Go th...

  • Richard Says:

    @Nexus Rex, Sure, just add this class to the field: class="required-entry input-text"...

  • Richard Says:

    @Kalamingo, Sure read this comment (http://www.richardcastera.com/2009/05/21/magento-display-new-pr...

Page optimized by WP Minify