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
2 years 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

The Importance of UX Design in Software Development The Importance of UX Design in Software Development

UX design is vital for user engagement, satisfaction, and the success of software applications in competitive markets.

2 years ago By Mitali Gupta
Real DOM VS Virtual DOM

In this article, we will discuss the differences between the real DOM and the virtual DOM in the context of web development. We'll explore how these concepts impact the performance and efficiency of web applications, and how they contribute to the overall user experience. By the end of this article, you'll have a clear understanding of the distinctions between these two approaches to managing and updating user interfaces on the web.

2 years ago By Mitali Gupta
What is CI/CD ? What is CI/CD ?

This article examines the meaning and significance of CI/CD in software development, emphasizing its role in improving the efficiency and reliability of software releases through automation and continuous integration and delivery.

2 years ago By Mitali Gupta
Best Websites for Building Resumes

In this article, we will explore five top websites that can assist you in crafting a compelling resume to increase your chances of getting shortlisted by companies.

2 years ago By Mitali Gupta