Bobcares

Connect to an Amazon RDS MySQL DB instance with Amazon RDS Proxy

by | Sep 27, 2021

Trying to connect to an Amazon RDS MySQL DB instance with Amazon RDS Proxy? Find out what our top Support Engineers have to say.

Are you having difficulty connecting your Amazon Relational Database Service DB instance with Amazon RDS proxy? Well, you have come to the right place. Bobcares is here to answer all your queries, big and small.

How to connect to an Amazon RDS MySQL DB instance with Amazon RDS Proxy

In order to connect your Amazon RDS MySQL DB instance with your Amazon RDS proxy, they both need to be in the same VPC. Although the database can be made publicly accessible, this is not an option for the proxy. Let’s see what our Support Engineers recommend:

    1. First, use AWS Secrets Manager to create database credentials.
    2. Then, create an IAM policy and IAM role.
    3. After that, create an Amazon RDS Proxy.
    4. Then, verify if the proxy endpoint is reachable:
      nc -zv  3306

This will result in an output similar to this:

nc -z test-proxy.proxy-xxxxxxxxxxxxx.eu-west-1.rds.amazonaws.com 3306
Connection to test-proxy.proxy-xxxxxxxxxxxxx.eu-west-1.rds.amazonaws.com 3306 port [tcp/mysql] succeeded!

Although, we would like to point out that you can run this command only on an EC2 machine in the same VPC as the proxy. The command will not run on local machines.

    1. Next. Connect to the RDS DB instance via the Amazon RDS proxy with this command:
      mysql -h  -u username -p

This results in an output similar to this:

mysql -h test-proxy.proxy-xxxxxxxxxxxxx.eu-west-1.rds.amazonaws.com -u admin -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2946664484
Server version: 5.7.28-log
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
Mysql>

You can also connect to the RDS DB instance via Amazon RDS Proxy with an SSL connection with these steps:

  1. First, enable Require Transport Layer Security when the Amazon RDS Proxy is created. Changing this parameter to Required ensures that connections use SSL.
  2. Next, go to Amazon Trust Services and download Amazon Root CA1 trust store .pem file.
    wget https://www.amazontrust.com/repository/AmazonRootCA1.pem
  3. Then connect via SSL:
    mysql -h test-proxy.proxy-xxxxxxxxxxxxx.eu-west-1.rds.amazonaws.com -u admin --ssl-mode=REQUIRED --ssl-ca=AmazonRootCA1.pem -p

    You can also use this command:

    mysql -h test-proxy.proxy-xxxxxxxxxxxxx.eu-west-1.rds.amazonaws.com -u admin --ssl-mode=VERIFY_IDENTITY --ssl-ca=AmazonRootCA1.pem -p

    Once connected, you will get the following output:

    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 12659040
    Server version: 5.7.28-log
    Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

    [Need assistance with Server Management? We are here to help.]

    Conclusion

    In short, we saw how easy it is to connect to Amazon Relational Database Service DB instance via Amazon RDS Proxy. The Support Team at Bobcares has a solution to any query.

    PREVENT YOUR SERVER FROM CRASHING!

    Never again lose customers to poor server speed! Let us help you.

    Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

    GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.