Here’s a quick method for migrating your WordPress blog from one hostname to another, for example http://some.domain to http://other.domain (on the same server). This method was tested on WordPress 2.6.1 with a MySQL database, but should be universally applicable. This method assumes you have shell access.
Create a backup directory
# mkdir ~/backup
Backup the WordPress filesystem hierarchy
# cd /path/to/website/root
# tar czf ~/backup/wordpress_sitename.tar.gz .
Backup the existing WordPress database
# cd ~/backup
# mysqldump -u db_user -p db_name > wordpress_db_name.sql
Make a copy of the existing WordPress database backup
# cd ~/backup
# cp wordpress_db_name.sql wordpress_new_db_name.sql
Edit wordpress_new_db_name.sql and replace all occurrences of some.domain with other.domain
(the following example is for the vi editor)
# vi wordpress_new_db_name.sql
:1,$s/some.domain/other.domain/g
Create the new WordPress database
# mysql -u root -p
mysql> create database new_db_name;
mysql> grant all on new_db_name.* to 'db_user'@'localhost' identified by 'your_password';
Restore the existing database into the new one
# cd ~/backup
# mysql -u db_user -p new_db_name < wordpress_new_db_name.sql
Modify the database name in wp-config.php
# cd /path/to/website/root
# vi wp-config.php
define('DB_NAME', 'new_db_name');
That’s it :)

