Heath SchweitzerHeath Schweitzer
← All posts

Migrating a WordPress database to a new host name

August 12, 2014|Heath Schweitzer|1 min read|53 views|Last Updated June 18, 2026

LinuxMacTechnology

process steps:

  1. export the database
  2. updated the static entries of the hostname in the database
  3. import the database

commands:

  1. mysqldump -u _USERNAME_ -p _DBNAME_ > _DBNAME_.sql
  2. cat _DBNAME_.sql | sed -e 's/_HOSTNAME_/_NEWHOSTNAME/g' > _DBNAME_UPDATED.sql
  3. mysql -u _USERNAME_ -p _DBNAME_ < _DBNAME_UPDATED.sql

options & variables:

  • _USERNAME_ = the the database user name
  • -p = will prompt for the password
  • _DBNAME_ = the name of the database
  • _HOSTNAME_ = the hostname of the existing server
  • _NEWHOSTNAME = the new hostname to use
  • _DBNAME_UPDATED = the name of the new updated SQL file

If this post was useful, consider buying me a coffee ☕ with ₿itcoin — no account needed, any amount welcome.

Bitcoin tip QR code
⚡ Open in Wallet