How can I use an SSH tunnel and MySQL Workbench to connect to a private Amazon RDS MySQL DB instance that uses a public EC2 instance?
Last updated: 2020-04-06
I have a private Amazon Relational Database Service (Amazon RDS) MySQL DB instance and a public Amazon Elastic Compute Cloud (Amazon EC2) instance, and I want to connect to them by using an SSH tunnel and MySQL Workbench. How can I do this?
Before you connect over an SSH tunnel using MySQL Workbench, confirm that the security group inbound rules, network access control lists (network ACLs), and route tables are configured to allow a connection between your EC2 instance and your RDS DB instance. Also confirm that the EC2 instance can be connected to over the internet using its public IP address from your local machine. For more information, see Scenarios for Accessing a DB Instance in a VPC.
- Open MySQL Workbench.
- Select MySQL New Connection and enter a connection name.
- Choose the Connection Method, and select Standard TCP/IP over SSH.
- For SSH Hostname, enter the public IP address of your EC2 instance.
- For SSH Username, enter the default SSH user name to connect to your EC2 instance.
- Choose SSH Key File, and select the .pem file used to connect from your file system.
- For MySQL Hostname, enter the database endpoint name.
- For MySQL Server Port, enter the port number that you use to connect to your database.
- For Username, enter the user name that you use to connect to your database.
- For Password, enter the MySQL user password.
- Choose Test Connection. After the test is successful, choose OK to save the connection.
After the connection is configured, you can connect to your private RDS DB instance using an SSH tunnel.