Created
October 25, 2016 22:07
-
-
Save goreilly/91a20b8e86d03c02f475f1e8b5d2cbc8 to your computer and use it in GitHub Desktop.
Import entire MySQL databases from command live over SSH tunnel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[client] | |
user=root | |
password=password | |
host=127.0.0.1 | |
port=3306 | |
[clientremote] | |
user=remote_username | |
password=remote_password | |
host=127.0.0.1 | |
port=3307 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function download_mysql | |
for db in $argv | |
mysqldump --defaults-group-suffix=remote --single-transaction -vBC $db | mysql $db | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
ssh -L 3307:127.0.0.1:3306 remote_database_server_hostname |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment