Moving a WordPress database to another domain

Posted by & filed under Wordpress.

Here are the SQL queries to update a WordPress database from one domain to another:

# define var for old site
SET @old_path = 'http://oldsite.com';

# set var for new site
SET @new_path = 'http://newsite.com';

UPDATE wp_options
    SET
        option_value = replace(
            option_value,
            @old_path,
            @new_path
        )
    WHERE
        option_name = 'home'
    OR
        option_name = 'siteurl';
		
UPDATE wp_posts
    SET
        post_content = replace(
            post_content,
            @old_path,
            @new_path
        ),
        guid = replace(
            guid,
            @old_path,
            @new_path
        );

Modified from this site

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Bitnami