使用Ruby on Rails和SSH访问远程服务器上的远程MySQL数据库

问题描述:

如何使用SSH对远程服务器上的远程MySQL数据库进行RoR数据库调用.我有主机ip,ssh用户名,ssh密码,db,db用户名,db密码和端口.我所看到的任何示例都只是在ruby脚本中显示了代码,但我不知道如何将该解决方案应用于我的Web应用程序.我需要更改database.yml文件中的任何内容吗?感谢您的帮助...

How do I use SSH to make my RoR db calls to a remote MySQL db on a remote server. I have the host ip, ssh username, ssh password, db, db username, db password, and port. Any examples I have seen show the code just in a ruby script but I do not know how to apply that solution to my web application. Do I need to change anything in my database.yml file? I appreciate any help...

解决方法是创建一个到目标数据库主机的SSH隧道,并将本地服务器指向它. 签出:如何配置Rails无需密码即可访问远程数据库

The way to go about this is to create an SSH Tunnel to the destination database host and point the local server to it. Check out: How do I configure Rails for password-less access to remote database