Skip to content

Instantly share code, notes, and snippets.

@metaodi
Created January 4, 2016 10:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save metaodi/3dc73226e40bef9ad650 to your computer and use it in GitHub Desktop.
Save metaodi/3dc73226e40bef9ad650 to your computer and use it in GitHub Desktop.
DB dump of WordPress
# create a new DB dump
mysqldump -u USERNAME -p --skip-extended-insert --skip-quick DB_NAME > dump.sql
# replace the domain name in the dump, this is needed if you plan to use the dump on another domain
sed 's/www\.example\.com/stage.example.com/g' < dump.sql > updated_dump.sql
# optional: re-create the database
mysql -u root -e"show databases;" | grep DB_NAME && mysql -u root -e"drop database DB_NAME;"
mysql -u root -e"create database DB_NAME;"
# apply the dump
mysql -u USERNAME DB_NAME < dump.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment