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...
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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
回答2:
You can connect to remote databases from Rails. Simply edit your database.yml
:
development:
adapter: mysql
encoding: unicode
pool: 5
username: username
password: password
host: hostname
port: port_number
database: database_name