Skip to content

Instantly share code, notes, and snippets.

@joshnesbitt
Created November 6, 2012 16:23
Show Gist options
  • Save joshnesbitt/4025792 to your computer and use it in GitHub Desktop.
Save joshnesbitt/4025792 to your computer and use it in GitHub Desktop.
A handy script to stream a MySQL dump into another database.
#!/bin/bash
SOURCE_USER=user
SOURCE_HOST=localhost
SOURCE_PASSWORD='password'
SOURCE_DATABASE=database
TARGET_USER=user
TARGET_HOST=localhost
TARGET_PASSWORD='password'
TARGET_DATABASE=database
mysqldump $SOURCE_DATABASE --user=$SOURCE_USER --host=$SOURCE_HOST --password=$SOURCE_PASSWORD | \
mysql --user=$TARGET_USER --host=$TARGET_HOST --password=$TARGET_PASSWORD $TARGET_DATABASE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment