V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
warcraft1236
V2EX  ›  Python

pymysql 怎么连接需要通过 ssh 跳转的数据库呢

  •  
  •   warcraft1236 · 2017-10-31 10:23:19 +08:00 · 3138 次点击
    这是一个创建于 2359 天前的主题,其中的信息可能已经有所发展或是发生改变。

    MySQL 的数据库所在的服务器需要通过一个跳板机才能连接

    像 Sequel Pro 这种软件可以提供这样的功能,但是我现在想用 Python 脚本做一些事情,需要登录数据库,查了一下 pymysql 的方法,好像没看到有这样的支持

    不知道有没有什么办法

    5 条回复    2017-10-31 11:40:13 +08:00
    okletswin
        1
    okletswin  
       2017-10-31 10:33:40 +08:00
    很简单
    打开 google (bing 和 baidu 未测试)
    输入关键字 python mysql ssh
    点击搜索
    wangking
        2
    wangking  
       2017-10-31 10:37:13 +08:00
    跳板机的话 你做一个 ssh 隧道不行吗
    RuiQ
        3
    RuiQ  
       2017-10-31 10:47:43 +08:00
    import sshtunnel
    congeec
        4
    congeec  
       2017-10-31 11:10:21 +08:00
    不需要加密: socat 直接转发
    需要加密:搜 ssh forwarding
    这些工具跟 mysql 无关,有 IP 和端口就行
    q397064399
        5
    q397064399  
       2017-10-31 11:40:13 +08:00
    ssh 转发到本地
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3833 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 04:24 · PVG 12:24 · LAX 21:24 · JFK 00:24
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.