将 Rails 应用程序连接到 Amazon RDS 服务器。在控制台中工作,但现在页面无法加载
我正在尝试将 RDS 数据库与我的 Rails 应用程序一起使用,因为最终我想将其放在 heroku 上。 (数据库大约10GB)。我无法连接它,但它似乎可以工作。如果我进入控制台,我可以运行 sphinx 搜索以及我需要的所有内容,但是当我启动服务器时,它似乎冻结了或发生其他情况。如果我单击“关于您的应用程序的环境”,则什么也不会发生。我在控制台中没有收到任何消息或任何内容。如果我尝试转到另一个页面,它只会尝试加载该页面,但不会去任何地方。
这是我的database.yml 的样子。
# development:
# adapter: postgresql
# encoding: unicode
# database: musicbrainz_post
# pool: 5
# username: postgres
# password:
development:
adapter: mysql2
#encoding: utf8
host: musicbrainz.somestuff.amazonaws.com
#port: 3306
#reconnect: false
database: musicbrainz
username: myusername
password: mypass
如果我注释掉旧的数据库配置,它就会工作并且页面会加载以及所有内容。但我想使用亚马逊数据库。
有谁知道这是为什么?或者我应该使用另一个数据库/主机?
任何帮助都会很棒!
I am trying to use a RDS database with my rails app since eventually I want to put it on heroku. (Database is about 10gb). I had trouble getting it to connect but it seems to be working. If I go into the console I can run sphinx searches and all that I need to but when I start the server it seems to freeze or something. If I click "About your application’s environment" nothing happens. I do not get any messages in the console or anything. If I try to go to another page it just tries loading the page but does not go anywhere.
Here is what my database.yml looks like.
# development:
# adapter: postgresql
# encoding: unicode
# database: musicbrainz_post
# pool: 5
# username: postgres
# password:
development:
adapter: mysql2
#encoding: utf8
host: musicbrainz.somestuff.amazonaws.com
#port: 3306
#reconnect: false
database: musicbrainz
username: myusername
password: mypass
If I comment out my old database configuration it works and the pages load and everything. But I want to use the amazon database.
Does anyone know why this is? Or is there another database/host I should be using?
Any help would be great!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
遇到同样的问题后,我发现了问题所在。问题是您需要使用 Ruby 1.9.3,而不是 Ruby 1.8.7。我认为该错误发生在 mysql2 gem 中。
因此修复方法是安装 Ruby 1.9.3。以下是我遵循的步骤:
注意:在开始任何这些步骤之前,请将终端设置为“作为登录 shell 运行命令”。对于 Ubuntu,打开终端,转到编辑 ->个人资料首选项。转到“标题和命令”。选中“作为登录 shell 运行命令”旁边的框,
祝你好运!
After experiencing the same problem I found out what the problem was. The problem is that you need to use Ruby 1.9.3 as opposed to Ruby 1.8.7. I think the bug is occuring in the mysql2 gem.
Therefore the fix is to install Ruby 1.9.3. Here are the steps I followed:
NOTE: Before starting any of these steps, set up your terminal to "Run command as a login shell". For Ubuntu, open the terminal go to Edit -> Profile Preferences. Go to "Title and Command". Check the box next to "Run command as a login shell"
Good luck!