Skip to content

Instantly share code, notes, and snippets.

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 SimpleBackups/a9a6a1ff69950c565cc2a438a129d6e3 to your computer and use it in GitHub Desktop.
Save SimpleBackups/a9a6a1ff69950c565cc2a438a129d6e3 to your computer and use it in GitHub Desktop.
Remote MySQL Database Backup/Dump
# Reference: https://simplebackups.com/blog/remote-mysql-database-backup-via-ssh-tunneling/
# Setting up an SSH tunnel interactively
ssh -L 3306:mysql-server:3306 username@mysql-server
# How use mysqldump via SSH tunnel
mysqldump -P 3336 -u dbuser -p password database_name > dumpfile.sql
# How to restore a MySQL backup via the command line through an SSH tunne
mysql -P 3336 -u dbuser -p password database_name < dumpfile.sql
# How to dump a remote MySQL database (without SSH tunneling)
mysqldump -h 12.345.678.91 -u sb_user -P 3306 -p database_name > database_backup.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment