Limited Period Offer : 20% Discount on online/offline courses, for more details call/whatsapp

How to connect aws RDS instance using mysql workbench

2 min read
1 year ago By Santosh Kshirsagar

If your rds instance is publicly accessible

Step 1: Obtain the RDS MySQL Endpoint and Credentials

  • Log in to your AWS Management Console and navigate to the Amazon RDS service.
  • Select your MySQL database instance from the list.
  • On the "Connectivity & security" tab, note down the "Endpoint" value. This is the hostname or IP address of your RDS MySQL instance.
  • Scroll down to the "Master username" section and note down the username and password. These credentials will be used to connect to the RDS instance.

Step 2: Install and Open MySQL Workbench If you haven't installed MySQL Workbench, download and install it from the official MySQL website.

Step 3: Open MySQL Workbench and Set up a New Connection

  • Launch MySQL Workbench and click on the "+" icon in the "MySQL Connections" section to create a new connection.
  • Provide a connection name in the "Connection Name" field.
  • Enter the RDS MySQL Endpoint in the "Hostname" field.
  • Enter the RDS MySQL port number (default is 3306) in the "Port" field.
  • Enter the username and password obtained from the RDS instance in the respective fields.
  • Click "Test Connection" to verify if the connection is successful. You should see a success message.

Step 4: Connect to the RDS MySQL Instance

  • Once the connection test is successful, click "OK" to save the connection.
  • Double-click on the newly created connection in the "MySQL Connections" section to establish a connection to the RDS MySQL instance.

You should now be connected to your Amazon RDS MySQL instance using MySQL Workbench. You can now execute queries, manage your databases, and perform other operations within MySQL Workbench.

Note: Ensure that your security group settings in AWS allow inbound traffic from your IP address to the RDS instance's port (default is 3306). If necessary, update the security group rules to allow access.

If your rds instance is not publicly accessible

Here's a general outline of the steps to connect to a non-public RDS MySQL instance using an SSH tunnel:

Step 1: Configure SSH Access:

  • Set up an EC2 instance within the same VPC as your RDS MySQL instance, or use an existing EC2 instance that has network connectivity to the RDS instance.
  • Ensure that the EC2 instance has SSH access enabled and that you have the SSH key pair associated with it.

Step 2: Create an SSH Tunnel:

Open a terminal or command prompt on your laptop and use the SSH command to create an SSH tunnel to the EC2 instance, forwarding a local port to the RDS MySQL instance's endpoint. The command syntax is:

ssh -i <path_to_ssh_key> -L <local_port>:<rds_endpoint>:<rds_port> ec2-user@<ec2_instance_ip> -N

Replace <path_to_ssh_key> with the path to your SSH private key file, <local_port> with the local port number you want to use (e.g., 3307), <rds_endpoint> with the RDS MySQL endpoint, <rds_port> with the RDS MySQL port (default is 3306), and <ec2_instance_ip> with the public IP address of the EC2 instance.

Step 3: Connect to the RDS MySQL Instance:

  • Open MySQL Workbench on your laptop.
  • Configure a new connection using the local port number you specified in the SSH tunnel command (e.g., 3307) as the connection port.
  • Use the RDS MySQL instance's hostname as the connection host.
  • Enter the RDS MySQL instance's username and password.
  • Attempt to connect to the RDS MySQL instance using the configured connection.

By setting up an SSH tunnel, you establish a secure connection from your laptop to the EC2 instance, and then the EC2 instance acts as a proxy to connect to the RDS MySQL instance within the VPC.

Jun 06, 2023 19:14 Back to Articles

Other Articles

Binary Tree

Binary Tree is a Non-Linear data structure which has atmost 2 child . A Binary tree is represented by a pointer to the topmost node (commonly known as the “root”) of the tree. If the tree is empty, then the value of the root is NULL. Each node of a Binary Tree contains the following parts:

1 year ago By Aniket Prajapati
EdKool.com Launches: A New Destination for All Things Education & Technology

We're delighted to announce the launch of EdKool.com, a unique platform designed to bridge the gap between education and technology.

1 year ago By Santosh Kshirsagar
Introducing ECMAScript 6 (ES6): A New Era for JavaScript Development Introducing ECMAScript 6 (ES6): A New Era for JavaScript Development

In this article, we'll explore the important changes and improvements that came with ECMAScript 6 (ES6), and how they've made JavaScript programming better.

1 year ago By Mitali Gupta
How to identify Stack Questions? How to identify Stack Questions?

In this article, you will get clarity about how to find any given question that can be solved using stack.

1 year ago By Aniket Prajapati