简体   繁体   English

如何通过CLI / PUTTY访问AWS RDS?

[英]How can access AWS RDS by CLI / PUTTY?

I am new to AWS , I can access EC2 user by putty. 我是AWS新手,我可以通过putty访问EC2用户。 Like this how can i connect AWS RDS by PUTTY ? 像这样我如何通过PUTTY连接AWS RDS?

I have AWS RDS Endpoint , If i try like the below 我有AWS RDS端点,如果我尝试如下

mysql -h testing.cx2wamr3cbzm.us-west-2.rds.amazonaws.com -P 3306 -u Username -p

I am getting some error like 我收到一些错误

ERROR 2003 (HY000): Can't connect to MySQL server on 'testing.cx2wamr3cbzm.us-west-2.rds.amazonaws.com' (110) ERROR 2003(HY000):无法连接到'testing.cx2wamr3cbzm.us-west-2.rds.amazonaws.com'上的MySQL服务器(110)

I think there is a problem with security group.I searched more, but its difficult to understand for me. 我认为安全组存在问题。我搜索的更多,但我很难理解。

I want to create database and assign rights ? 我想创建数据库并分配权限?

Thanks 谢谢

RDS is not available to the world by default. 默认情况下,全世界都无法使用RDS。 It's also generally a bad idea to allow access to the RDS from anywhere except from inside your VPC. 除了从VPC内部以外的任何地方允许访问RDS通常也是一个坏主意。 I recommend you do the following: 我建议你做以下事情:

Create a security group that allows access to the RDS over port 3306 from your EC2 instance 创建一个安全组,允许从EC2实例通过端口3306访问RDS

  1. Visit https://console.aws.amazon.com/ec2/home#s=SecurityGroups and create a new security group. 访问https://console.aws.amazon.com/ec2/home#s=SecurityGroups并创建一个新的安全组。
  2. Switch to the inbound tab and choose MYSQL from the dropdown. 切换到入站选项卡,然后从下拉列表中选择MYSQL
  3. Erase the 0.0.0.0/0 in the source field then click the input field. 擦除源字段中的0.0.0.0/0,然后单击输入字段。 It will present you with a list of existing security groups. 它将显示现有安全组的列表。 Choose the one that your EC2 instance belongs to. 选择您的EC2实例所属的那个。
  4. Click the apply rule changes button 单击“ 应用规则更改”按钮

Assign the security group to your RDS 将安全组分配给RDS

  1. Visit https://console.aws.amazon.com/rds/home#dbinstances : and select your RDS instance and under the Instance Actions menu select Modify 访问https://console.aws.amazon.com/rds/home#dbinstances :并选择您的RDS实例,然后在Instance Actions菜单下选择Modify
  2. Change the RDS security group to the one you just created 将RDS安全组更改为刚刚创建的安全组
  3. Make sure to select the Apply immediately option at the bottom of this page 确保选择本页底部的立即应用选项
  4. Click Continue and apply the new changes. 单击“继续”并应用新更改。 (the change can sometimes take a couple of minutes) (这种变化有时可能需要几分钟)

SSH into your EC2 instance then run the mysql command in your question SSH进入您的EC2实例然后在您的问题中运行mysql命令

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

相关问题 我无法通过 Putty 访问 AWS RDS MySQL 数据库 - I can't access AWS RDS MySQL database via Putty Amazon RDS:如何限制 RDS 实例对 AWS Lambda 函数和到我的计算机的访问? - Amazon RDS: How can I limit the RDS instance access to AWS Lambda functions and TO My computer? 如何使用 AWS CLI 将 RDS 代理添加到 AWS Lambda - How to add RDS Proxy to AWS Lambda using AWS CLI 如何从 AWS CLI 连接到 AWS RDS PostgreSql 实例 - How to connect to AWS RDS PostgreSql Instance from AWS CLI 如何使用 AWS CLI 获取 RDS 数据库实例的最新快照的名称? - How can I get the name of the most recent snapshot for an RDS DB instance using the AWS CLI? 如何在CLI中将AWS-RDS aurora数据库还原到指定时间? - How can I restore AWS-RDS aurora database to a specified time in CLI? 如何获取使用 AWS CLI 手动创建的 RDS 数据库实例的所有快照的名称? - How can I get the name of the all snapshot of RDS DB instance created manually using the AWS CLI? AWS RDS:如何从本地主机访问/连接到RDS MySql DB - AWS RDS: How to access/connect to RDS MySql DB From localhost 如何使用AWS CLI知道RDS免费存储? - How to know RDS free storage with using AWS CLI? 如何从 C# 访问 AWS CLI 资源? - How can I access AWS CLI resources from C#?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM