Let's connect VS Code with RDS for MySQL

Let's connect VS Code with RDS for MySQL

What is Amazon Relational Database Service (RDS)?

Amazon Relational Database Service (Amazon RDS) is a web service that makes it easier to set up, operate, and scale a relational database in the AWS Cloud. It provides cost-efficient, resizable capacity for an industry-standard relational database and manages common database administration tasks.

LAB: Connect VS Code with Amazon RDS

In this lab, we are going to create a basic database in RDS to understand how to establish the connection between the RDS database and VS Code. So that we can access the database created in RDS and use it from VS Code text editor.

Step 1: Create a Database in RDS

  • Search RDS and Select it

  • Then Click on Create database and config as the information given:

    • Choose a database creation method: Standard

    • Engine option: MySQL

    • Templates: Free tier

    • Settings:

      • DB instance identifier: demo-db

      • Credentials Settings > Master Username: admin

      • Credentials Settings > Master password: **********

      • Credentials Settings > Confirm master password: **********

    • Storage:

      • Storage type: General Purpose SSD(gp2)

      • Storage autoscaling: you can uncheck Enable storage autoscaling

    • Connectivity:

      • Compute resource: Don’t connect to an EC2 compute resource

      • Virtual private cloud (VPC): Default VPC

        { Note: If you don't have Default VPC and don't know how to create VPC you can learn from my Here and comment if any doubt. }

      • Public access: Yes

      • VPC security group (firewall): Leave default

      • Availability Zone: You can choose any

    • Database authentication: Check Password authentication

    • Monitoring: Unchecked

    • Additional configuration:

      • Initial database name: demo

      • Backup: Uncheck enable automated backups

      • Encryption: Uncheck Enable encryption

  • Leave all Default and Create database

    • After sometime when Status of database modifying or Available

    • click on demo-bd -> Scroll down in Connectivity & Security

    • For future use Copy Endpoint marked as:

Step 2: Update VPC Default Security group as:

  • Search VPC and Select it

  • Scroll the left-side-bar and select the security groups

  • Click on the Security group ID which has the Security group name: default

  • Click on Edit inbound rules

    • Click Add rule

      • Type: MYSQL/Aurora

      • Source: Anywhere-IPv4 i.e. (- If you created a new security group add this rule as inbound as well )

    • Save rules

Step 3: Work with VS Code

  • Install VS Code

  • Download following extensions

  • Create any directory or folder on your computer

  • open the folder and right click

  • Click on Open in Terminal and type the following command to open that folder in VS Code directly

      code .
  • Click on SQLTools symbol

  • Also, click on Add New Connection

  • Select MySQL and fill as:

  • Click on TEST CONNECTION enter the password you set above while creating RDS

  • You should get Successfully connected! message



Now you can do any SQL query and run on VS Code...

Thank you for LEARNING !!!