I have an SSH access to production server of the Rails app.
I want to make a mysqldump of production database to my Mac. Please help me to achieve this.
By using SSH, it is very easy to create a backup (dump) of your entire database. Once at the shell prompt, type in the following command and press [enter]: mysqldump -h 127.0. 0.1 -u db_user -p db_name > db_backup.
Direct method to dump mysql data from remote server to your local computer is:
ssh root@ipaddress "mysqldump -u dbuser -p dbname | gzip -9" > dblocal.sql.gz
Or
ssh -l root ipaddress "mysqldump -u dbuser -p dbname | gzip -9" > dblocal.sql.gz
Both command does the same work.
If you have password for ssh and database access there will two prompt for password or if you have no password for ssh then you will be asked to enter you database password.
Similarly, if you are using key from aws or cloud other service you can incorporate the key in the command as:
ssh -i key.pem root@ipaddress "mysqldump -u dbuser -p dbname | gzip -9" > dblocal.sql.gz
ssh remote_username@remote_host
mysqldump -u username -ppassword -h host database > dump.sql
scp remote_username@remote_host:/path/to/dump.sql /Users/YourName/Documents/dump.sql
rm dump.sql
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With