DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Transfer Wordpress MySQL Database To New Webhost

04.14.2008
| 3664 views |
  • submit to reddit
        // Transfer Wordpress MySQL database to new webhost in 3 steps (assumes: A. files have already been copied over, B. database created on new server, C. database user created on new server, D. wp-config.php updated on new server)
// 1. login to old host via ssh, run this command:
mysqldump -h DB_HOST -u DB_USER -p DB_NAME > dump.sql
// replace DB_HOST, DB_USER, & DB_NAME with info from the local wp-config.php file
// when asked for password, enter DB_PASSWORD from the local wp-config.php file

// 2. copy dump.sql to your new host using sftp

// 3. login go new host via ssh, run this command:
mysql -h DB_HOST -u DB_USER -p DB_NAME < dump.sql
// replace DB_HOST, DB_USER, & DB_NAME with info from the local wp-config.php file
// when asked for password, enter DB_PASSWORD from the local wp-config.php file

// adopted from this page: http://technosailor.com/2007/04/06/wordpress-faq-how-do-i-move-my-blog-to-a-new-host/