Connecting to Amazon RDS


#1

When trying to connect to an RDS mysql database the connection always times out, any advice?

Command used to connect is:
mysql -u root -p -h rds.amazonaws.com

Thanks in advance.


#2

Hi,

First, you have to make sure your RDS instance is publicly accessible :

  • In aws console go to your instances list
  • Select modify in the action toggle buton
  • Choose yes for “publicly accessible” parameter in the network & accesibility section
  • Scroll down, check the “apply immediatly” box
  • Validate by clicking on the continue button
  • Wait for your instance to restart

After that you have to grab the public IP of your cloud 9 instance :

  • In cloud 9 IDE, click on window > new terminal
  • Run the following command : dig +short myip.opendns.com @resolver1.opendns.com
  • The returned value is the public IP adress of you C9 instance : copy it.

Finaly, you have to authorize your C9 instance to connect to the RDS instance :

  • In AWS console, go to the VPC attached to your RDS instance
  • In the inbound tab, click on add a new rule
  • For the type, choose, mysql/aurora in the dropdown menu
  • Leave other parameters by default, except for the source. The value must be a valide CIDR, so you can enter <ip_adress_of_my_cloud_9_instance>/32 . Of course, do not forget to replace by your real C9 instance IP adress value !!

To check everything is OK, you can go back to the teminal and enter the following command : mysql -h"<my_amazon_endpoint_url>" -u<database_username> -p<password>

Normally you should see the mysql command prompt…

Hope this will help…

Cheers


#3

Thanks!! they work :slight_smile:


#4

Note that to make this work for real you have to add all the IPs to the whitelist.

104.199.226.78
104.155.232.163
130.211.242.207
104.199.207.212
104.155.237.197
104.199.221.81
104.199.200.118
104.199.166.46
104.199.147.151
104.199.167.187
104.199.215.72
104.155.227.126
104.199.187.105
104.199.204.195
104.155.218.91
104.199.227.129
104.155.229.8
104.155.201.213
104.199.160.209
104.199.227.228
104.155.222.52
104.199.225.98
104.199.216.253
104.199.168.139
104.199.207.189
35.187.0.184
104.155.83.209
104.155.18.187
104.155.102.56
104.155.71.139
104.155.106.228
104.155.66.198
104.199.69.103
104.199.49.172
104.199.104.184
146.148.25.160
104.199.53.7
130.211.63.70
104.199.21.207
104.199.71.196
104.199.85.101
104.199.75.149
104.199.78.94
104.199.85.158
104.199.52.182
104.199.95.237
130.211.70.196
146.148.9.161
104.199.56.106
104.199.34.52
146.148.12.165
104.199.92.203
104.199.8.125
104.199.54.126
104.155.118.152
104.199.1.29
104.199.2.199
104.199.108.97
104.199.42.243
104.199.23.99
104.199.73.164
104.199.62.166
130.211.61.107
104.155.119.141
146.148.127.2
104.199.22.129
104.199.74.213
104.199.73.19
104.155.18.242
104.199.27.148
23.251.128.138
23.251.143.239
104.199.3.28
104.155.103.151
104.199.110.25
104.155.125.101
104.155.10.247
130.211.95.196
104.155.173.236
23.251.159.15
104.154.109.53
104.198.30.228
146.148.38.35
130.211.165.203
104.154.32.125
104.154.129.226
104.198.39.141
104.198.134.226
104.198.171.151
104.198.223.70
104.198.35.139
104.197.182.64
104.198.132.167
104.197.100.160
104.154.74.221
104.154.72.189
104.154.156.22
104.197.11.131
23.236.49.177
104.198.19.159
23.236.54.201
104.198.136.225
104.198.155.191
104.198.163.47
104.197.172.66
104.198.196.236
104.155.189.30
104.154.137.220
104.155.190.133
104.198.233.180
23.236.56.166
104.197.56.193
104.198.66.50
104.198.138.17
104.154.65.214
104.197.153.31
104.197.64.166
104.154.238.48
104.154.56.244
104.154.42.147
23.236.60.97
104.154.241.193
104.198.148.92
104.154.113.166
104.198.248.100
104.198.17.175
107.178.214.250
104.154.89.6
104.155.133.75
130.211.135.59
104.154.234.160
104.198.135.145
104.198.147.151
104.198.147.74
130.211.158.21
104.197.36.238
146.148.43.99
104.198.23.67
104.154.139.126