Moving A WordPress Site To A Different Domain Name

Suppose you want to make a copy of your existing WordPress site on a different domain name (e.g. Instead, maybe you want to move your site to a different domain name (e.g. This procedure assumes you have shell access to the Linux server hosting your site running Apache & MySQL.

  1. Copy the web directory:
    cp -pR
  2. Dump the MySQL database
    mysqldump -l wordpress-old > wordpress-old-dump
  3. Login to MySQL. Create a new database and load from the dump:
    create database wordpress-new;
    use database wordpress-new;
    source wordpress-old-dump;
  4. Create a new database user for the new WordPress instance:
    CREATE USER 'wordpress-user'@'localhost' IDENTIFIED by 'some-password';
  5. Give your WordPress MySQL user permissions on the new database:
    GRANT ALL ON wordpress-new.* TO 'wordpress-user'@'localhost';
  6. Edit your new wp-config.php: enter the appropriate database name, username, and password:
    define('DB_NAME', 'wordpress-new');
    define('DB_USER', 'wordpress-user');
    define('DB_PASSWORD', 'some-password');
  7. Configure the new site in Apache: The steps here are different depending on your distribution. Essentially, you want a new site pointing to the new web directory. Relevant items:
    DocumentRoot /path/to/
  8. Log back into MySQL and fix-up the URLs:
    use database wordpress-new;
    UPDATE wp_posts SET post_content = replace(post_content, '', '');
    UPDATE wp_posts SET guid = replace(guid, '','');
    UPDATE wp_postmeta SET meta_value = replace(meta_value,'','');
    UPDATE wp_options SET option_value = replace(option_value, '', '') WHERE option_name = 'home' OR option_name = 'siteurl';
  9. That’s it! Open up a browser and go to your You should check your site for any hard link references to in Pages, Posts, and RSS Feeds.