Skip to content

Instantly share code, notes, and snippets.

@antoniomaria
Created August 16, 2022 05:59
Show Gist options
  • Save antoniomaria/8d09e5acdb1c2bc2ecb715586466a0b1 to your computer and use it in GitHub Desktop.
Save antoniomaria/8d09e5acdb1c2bc2ecb715586466a0b1 to your computer and use it in GitHub Desktop.
SSH Tunnel to AWS RDS or Aurora DB instance via EC2 instance
# Verify that you have access to your ec2 instance which has access to DB
ssh -i mykey.pem ec2-user@EC2_IP_ADDRESS
# Use tunnel port forwarding
ssh -i mykey.pem -L 3306:RDS-HOST-NAME:3306 ec2-user@IP-ADDRESS
# Connect to localhost
mysql -h 127.0.0.1 -P 3306 -u admin -p12345678
@antoniomaria
Copy link
Author

Ensure that you don't have a local mysql instance running in the same port
lsof -i :3306

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment