Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can access AWS RDS by CLI / PUTTY?

I am new to AWS , I can access EC2 user by putty. Like this how can i connect AWS RDS by PUTTY ?

I have AWS RDS Endpoint , If i try like the below

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)

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

like image 835
Rajaraman Avatar asked Jan 09 '14 12:01

Rajaraman


People also ask

How do I access RDS from AWS CLI?

Sign in to the AWS Management Console and open the Amazon RDS console at https://console.aws.amazon.com/rds/ . In the navigation pane, choose Databases to display a list of your DB instances. Choose the name of the MySQL DB instance to display its details. On the Connectivity & security tab, copy the endpoint.


1 Answers

RDS is not available to the world by default. It's also generally a bad idea to allow access to the RDS from anywhere except from inside your VPC. I recommend you do the following:

Create a security group that allows access to the RDS over port 3306 from your EC2 instance

  1. Visit https://console.aws.amazon.com/ec2/home#s=SecurityGroups and create a new security group.
  2. Switch to the inbound tab and choose MYSQL from the dropdown.
  3. Erase the 0.0.0.0/0 in the source field then click the input field. It will present you with a list of existing security groups. Choose the one that your EC2 instance belongs to.
  4. Click the apply rule changes button

Assign the security group to your RDS

  1. Visit https://console.aws.amazon.com/rds/home#dbinstances: and select your RDS instance and under the Instance Actions menu select Modify
  2. Change the RDS security group to the one you just created
  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

like image 181
Keegan Lillo Avatar answered Sep 28 '22 07:09

Keegan Lillo