我想简化 SSH 隧道来做一个 MySQL 转储和 SCP 文件到本地机器 [英] I would like to simplify SSH Tunneling to do a MySQL Dump and SCP the file to local machine

查看:45
本文介绍了我想简化 SSH 隧道来做一个 MySQL 转储和 SCP 文件到本地机器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

服务器设置(假IP)

  • 实用程序 - 1.1.1.1 - 公共 IP 上的 SSH 访问
  • database2 - 1.1.1.2 - 来自实用程序的私有 IP 上的 SSH 访问

在半定期的基础上,我需要在 database2 上执行 mysqldump 并将其拉到我的本地机器上,以便我可以使用真实数据调试我们的应用程序.我目前的流程如下:

On a semi-regular basis I need to do a mysqldump on database2 and pull that down to my local machine so I can debug our app with real data. My current process is as follows:

  • ssh 进入实用程序
  • ssh 进入数据库 2
  • 执行mysqldump命令
  • 退出数据库 2
  • scp 转储文件到实用程序
  • 退出实用程序
  • scp 转储文件到本地机器

不用说这不是最佳的.有没有一种更快的方法,可能是通过隧道,我可以使用我的设置?

Needless to say this is not optimal. Is there a quicker method, possibly via tunneling, that I could use given my setup?

推荐答案

你可以

  1. 通过 cron 在 database2 上进行转储
  2. 在实用程序上转发端口并立即连接到数据库 2

总结:您将通过一个 scp 命令获得转储.

summary: you will get dump by one scp command.

更新:

如果你不能转发或cron,你可以从实用程序添加对数据库的访问并从他那里制作mysqldump.

if you can't port forward or cron, you can add access to database from utility and make mysqldump from him.

这篇关于我想简化 SSH 隧道来做一个 MySQL 转储和 SCP 文件到本地机器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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