【问题标题】:How do I reverse engineer over an SSH tunnel with Propel?如何使用 Propel 在 SSH 隧道上进行逆向工程?
【发布时间】:2014-10-29 09:52:59
【问题描述】:

我只能通过 SSH 隧道连接到我的数据库。到目前为止,我一直在从我的数据库中转储模式并将其加载到我的本地。如何直接连接到我的数据库?

【问题讨论】:

    标签: php mysql propel


    【解决方案1】:

    互联网上完全缺乏这些信息,所以我正在回答我自己的问题。

    1. 关闭本地 MySQL 服务器实例(如果有的话)。
    2. 打开终端并运行以下命令:

      ssh -L 3307:[database hostname]:3306 [SSH username]@[SSH hostname] [-p[SSH port]]
      

      这可能也适用于 PuTTY,我不确定。

    3. 在您的 build.properties 中,设置以下内容:

      propel.database.url=mysql:host=0.0.0.0;port=3307;dbname=[database name]
      

    不能是本地主机。如果是,您将收到以下错误:

    propel > reverse:
    
         [echo] +-----------------------------------------------+
         [echo] |                                               |
         [echo] | Generating XML from PDO connection !          |
         [echo] |                                               |
         [echo] +-----------------------------------------------+
    [propel-schema-reverse] There was an error building XML from metadata: vendor/propel/propel1/generator/build-propel.xml:296:1: SQLSTATE[HY000] [2002] No such file or directory
    
    BUILD FINISHED
    
    Total time: 0.2293 seconds
    

    这个神秘的错误意味着它无法在您的计算机上找到 Unix 套接字,因为 even if you are specifying the host and the port,PDO 仍然会寻找带有 localhost 的套接字。显然,您永远不能为不在您机器上的服务器打开套接字,即使您将 unix_socket 添加到 DSN 为空,它也会抱怨文件名错误。使用0.0.0.0 修复了这个错误。我实际上是从this question 发现的。

    你就完成了!您现在可以通过 SSH 隧道使用 Propel 进行逆向工程。

    【讨论】:

      猜你喜欢
      • 2019-02-04
      • 2015-04-28
      • 2017-04-01
      • 1970-01-01
      • 2020-01-08
      • 1970-01-01
      • 2012-06-06
      • 2015-01-24
      • 2018-04-26
      相关资源
      最近更新 更多