The scenario:
- We have connectivity to remote server (EC2 instance)
REMOTE_EC2_HOST
over SSH. - Connectivity to AWS RDS MySQL instance
RDS.ENDPOINT.rds.amazonaws.com
from remote server only (due to security group/firewall settings).
# forward requests from 127.0.0.1:6400 -> RDS.ENDPOINT.rds.amazonaws.com:3306
# add [-f] switch to background ssh process
$ ssh -vvvN \
-L 6400:RDS.ENDPOINT.rds.amazonaws.com:3306 \
-i /path/to/rsa/private/key \
USERNAME@REMOTE_EC2_HOST
# connect to MySQL on 127.0.0.1:6400
$ mysql --host 127.0.0.1 --port 6400 --user MYSQL.USER --password