mysqldump通过SSH到本地计算机 [英] mysqldump via SSH to local computer

查看:384
本文介绍了mysqldump通过SSH到本地计算机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以通过SSH访问Rails应用程序的生产服务器.

I have an SSH access to production server of the Rails app.

我想将生产数据库的mysqldump创建到我的Mac.请帮助我实现这一目标.

I want to make a mysqldump of production database to my Mac. Please help me to achieve this.

推荐答案

将mysql数据从远程服务器转储到本地计算机的直接方法是:

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 

ssh -l root ipaddress "mysqldump -u dbuser -p dbname | gzip -9" > dblocal.sql.gz

两个命令都执行相同的工作.

Both command does the same work.

如果您具有用于ssh的密码和数据库访问权限,则会出现两个提示输入密码的提示,或者如果您没有用于ssh的密码,那么系统将要求您输入数据库密码.

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.

类似地,如果您正在使用来自AWS或其他服务的密钥,则可以将密钥合并为命令:

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

这篇关于mysqldump通过SSH到本地计算机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆