Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Dump a mysql database remotely and importing it locally.
#!/bin/bash
SSH_SERVER=server.com
SSH_USER=user
REMOTE_DB_USER=remotedbuser
REMOTE_DB_PASSWORD=remotedbpassword
REMOTE_DB_SCHEMA=remotedbschema
LOCAL_DB_USER=localdbuser
LOCAL_DB_PASSWORD=localdbpassword
LOCAL_DB_SCHEMA=localdbschema
ssh $SSH_USER@$SSH_SERVER "mysqldump -u$REMOTE_DB_USER -p$REMOTE_DB_PASSWORD --default-character-set=utf8 --opt $REMOTE_DB_SCHEMA" | mysql -u$LOCAL_DB_USER -p$LOCAL_DB_PASSWORD $LOCAL_DB_SCHEMA
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.