简体   繁体   中英

AWS RDS: How to access/connect to RDS MySql DB From localhost

I am very new to Amazon Web Services, I have created Mysql DB on RDS and stored some data.

Now i want to connect to RDS db from localhost(which is in running on my desktop) ,Tried as fallow in my PHP connection.

$con = mysql_connect("XXXX.XXXXX.XX-XX-X.rds.amazonaws.com:3306", "XXX", "XXX");

But getting error as fallows

Could not connect: Can't connect to MySQL server on 'awsniti.XXXX.rds.amazonaws.com'

Also tried giving my local IP address to Inbounds of Security Group. But couldn't connect.

googled a lot, but not able to find right answer.

Please help me with this issue.

Adding the internet IP of your local network/machine on the security group associated with your RDS database should work. But I prefer to create a SSH tunnel through a server that I already gave access to the database. This way you don't have to care about the security group configuration every time you need to connect from a different IP address.

If you are on Linux or OSX you can run locally ssh -f user@your-web-server.com -L 3306:XXXX.XXXXX.XX-XX-X.rds.amazonaws.com:3306 -N and then connect localhost:3306 from PHP to access the RDS database. If you are on Windows it's also possible to create a tunnel using Putty ( http://bit.ly/1GQmaYo )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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