简体   繁体   English

Amazon RDS未知MYSQL主机

[英]Amazon RDS Unknown MYSQL Host

I've been trying to connect to an RDS database from an application I'm hosting on elastic beanstalk. 我一直在尝试从我在弹性beanstalk上托管的应用程序连接到RDS数据库。 It gives me this error: 它给了我这个错误:

[Instance: i-0f0051f7599e17190] Command failed on instance. Return code: 1 
Output: (TRUNCATED)... -s /bin/bash -c 'leader_only bundle exec rake 
db:migrate' webapp rake aborted! Mysql2::Error: Unknown MySQL server host 
'xxxxxxxxxx.xxxxxxxxx.us-west-2.rds.amazonaws.com' (25) Tasks: TOP => 
 db:migrate (See full trace by running task with --trace). Hook 
/opt/elasticbeanstalk/hooks/appdeploy/pre/12_db_migration.sh failed. For 
more detail, check /var/log/eb-activity.log using console or EB CLI.

The server host is the correct hostname of the database, I just x'd it out. 服务器主机是数据库的正确主机名,我只是将其解析出来。
I am able to connect to and view this database via the MYSQL workbench but not on localhost or AWS. 我可以通过MYSQL工作台连接并查看此数据库,但不能在localhost或AWS上连接和查看。 I've tried putting the host in manually rather than using a variable but that gave me the same error 我已经尝试手动放置主机而不是使用变量,但这给了我同样的错误

Here is where I try to connect in my database.yml file 这是我尝试在database.yml文件中连接的地方

production:
  adapter: mysql2
  encoding: utf8
  database: <%= ENV['RDS_DB_NAME'] %>
  username: <%= ENV['RDS_USERNAME'] %>
  password: <%= ENV['RDS_PASSWORD'] %>
  host: <%= ENV['RDS_HOSTNAME'] %>
  port: <%= ENV['RDS_PORT'] %>

I've also tried messing around with the security groups but nothing really changes 我也试过搞乱安全组但没有真正改变

When I try to connect on localhost it gives me 当我尝试连接localhost时,它给了我

MYSQL2 Error Can't connect to MySQL server on 'localhost' (10061) MYSQL2错误无法连接到'localhost'上的MySQL服务器(10061)

The above issue is due to your EC2 instance is not having access to your MYSQL RDS. 上述问题是由于您的EC2实例无法访问您的MYSQL RDS。 Please add the access and your app will start working. 请添加访问权限,您的应用将开始工作。 Please follow this guide http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_WorkingWithSecurityGroups.html#USER_WorkingWithSecurityGroups.AuthorizingEC2 请遵循本指南http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_WorkingWithSecurityGroups.html#USER_WorkingWithSecurityGroups.AuthorizingEC2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM