Migrating data between local and development server

Assuming your wp-config.php is already in place and in order:

  • Step 1. Mysqldump your development database
  • Step 2. Replace all instances of development.domain.com to production.domain.com^^
  • Step 3. Login to MySQL, run a SOURCE command to import data e.g. source /path/to/file

^^ How to replace all instances of old domain with new: (1) Copy the script below. (2) chmod +x it. (3) Run it.

Usage: ./script.sh development-dump.sql > production-dump.sql

#!/bin/sed -f
s/'\([^\\']*\)development.domain.com\([^\\']*\)"https://wordpress.stackexchange.com/"\1production.domain.com\2'/g

Leave a Comment