Created
November 9, 2023 12:54
-
-
Save SimpleBackups/a9a6a1ff69950c565cc2a438a129d6e3 to your computer and use it in GitHub Desktop.
Remote MySQL Database Backup/Dump
This file contains hidden or 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
# 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