使用MySql2将Heroku连接到RDS [英] Connecting Heroku to RDS using MySql2

查看:189
本文介绍了使用MySql2将Heroku连接到RDS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做的是在Heroku上使用RDS上的db实例部署我的Rails应用程序,这看起来应该很简单。



我是在我的 database.yml 中使用mysql2适配器,并推送到heroku并添加了我的数据库实例(这个答案。我基本上跟着它到了T,并且我没有得到缺少gem 的错误。但这就是 heroku日志揭示的内容:

  / app / vendor /bundle/ruby/1.9.1/bundler/gems/mysql2-e5992664a7bc/lib/mysql2/client.rb:56:in connect':无法连接到'nickcoxrails.cud3e2tma07q.us-east-1上的MySQL服务器。 rds.amazonaws.com'(110)(Mysql2 :: Error)

另请注意,我的RDS实例在我们东部,我听说这是一个问题这里

在我的gemfile中,我有:

gem'mysql2', :git => 'git://github.com/brianmario/mysql2.git'



对于我的mysql2 gem,因为这是我可以得到的唯一方法它在本地工作(因为我的本地Rails服务器上使用的版本<0.3每个第一个答案给我一个错误,因为我在Rails 3.2.6),尝试了很多事情(我真的无法让MySQL运行我的本地机器)。



我已经明确地为每个这个答案,并已添加mysql2数据库每这个答案。我还在我的heroku帐户中添加了RDS插件。我运行了 rake db:create rake db:schema:load rake db:migrate 和所有内容,但是由于我将本地数据库导出到了我的RDS实例(我需要保持这些数据不变),所以没有任何新功能。我可以通过Sequel Pro连接到我的RDS实例,所以我知道它不是凭证问题。



这是我的第一个Rails应用程序部署,所以不要害怕贬低你的答案,给我相当于是否插入?技术支持问题为heroku / Rails / RDS /等。

解决方案

确保您已授权安全组 default 。错误消息表明您的连接不被允许。


All I'm trying to do is deploy my Rails app on Heroku with a db instance on RDS, which seems like it should be straightforward.

I'm using the mysql2 adapter in my database.yml and have pushed to heroku and added my db instance per this answer. I've basically followed it to a T, and I don't get a missing gem error. But this is what the heroku logs reveal:

/app/vendor/bundle/ruby/1.9.1/bundler/gems/mysql2-e5992664a7bc/lib/mysql2/client.rb:56:in connect': Can't connect to MySQL server on 'nickcoxrails.cud3e2tma07q.us-east-1.rds.amazonaws.com' (110) (Mysql2::Error)

Also notice that my RDS instance is in us-east, which I heard is an issue here.

In my gemfile, I have:

gem 'mysql2', :git => 'git://github.com/brianmario/mysql2.git'

for my mysql2 gem because it was the only way I could get it working locally (because using the version < 0.3 per that first answer gave me an error on my local rails server because I'm on Rails 3.2.6), having tried a number of things (I really had trouble getting mysql running on my local machine).

I have definitely added the security groups per this answer and have added the mysql2 database per this answer. I have also added the RDS add-on in my heroku account. I ran rake db:create and rake db:schema:load and rake db:migrate and everything, but since I exported my local db to my RDS instance (I need to keep that data intact), none of that does anything new. And I can connect to my RDS instance through Sequel Pro, so I know its not a credentials issue.

This is my first Rails app deployment, so don't be afraid to dumb down your answers and give me the equivalent of the "Is it plugged in?" tech support questions for heroku/Rails/RDS/etc.

解决方案

Make sure you have authorized the security group default from AWS account 098166147350 which is owned by Heroku. The error message suggests that your connection is not being allowed.

这篇关于使用MySql2将Heroku连接到RDS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆