# 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
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686659853658/6b02c07a-b6f7-4dcd-88c7-ff8d241f93f8.jpeg align="center")
    
* **Then Click on <mark>Create database </mark> 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 &gt; Master Username: `admin`
            
        * Credentials Settings &gt; Master password: `**********`
            
        * Credentials Settings &gt; Confirm master password: `**********`
            
    * Storage:
        
        * Storage type: `General Purpose SSD(gp2)`
            
        * Storage autoscaling: <mark>you can uncheck </mark> `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](https://blog.lokendrabhat1.com.np/amazon-virtual-private-cloud-vpc). }
            
        * 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: <mark>Uncheck </mark> `enable automated backups`
            
        * Encryption: <mark>Uncheck </mark> `Enable encryption`
            
* Leave all Default and **<mark>Create database</mark>**
    
    * After sometime when `Status` of database `modifying` or `Available`
        
    * click on `demo-bd` -&gt; Scroll down in `Connectivity & Security`
        
    * For future use Copy `Endpoint` marked as:
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686662689316/c50ab6b2-9627-4284-8d33-ddf78aad8b8b.jpeg align="center")
        

### 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. `0.0.0.0/0` (- If you created a new security group add this rule as inbound as well )
            
    * **<mark>Save rules</mark>**
        

### Step 3: Work with VS Code

* Install VS Code
    
* Download following extensions
    
    * ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686661707671/a09fc485-ba98-4de5-8baf-49b57f503ef3.jpeg align="center")
        
    * ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686661695547/61ff90cd-a81a-47ec-8e05-f0778577767a.jpeg align="center")
        
    * ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686661676946/8f1ebcc3-3280-45c7-8c35-2dca66bf9501.jpeg align="center")
        
* Create any directory or folder on your computer
    
* open the folder and right click
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686662003298/687820b8-1fbe-4b3b-9dcb-c98ee0ac93f2.jpeg align="center")
    
* Click on Open in Terminal and type the following command to open that folder in VS Code directly
    
    ```bash
    code .
    ```
    
* Click on `SQLTools` symbol
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686662276861/f9313e79-94b8-41fb-84b6-7650d25b399a.jpeg align="center")
    
* Also, click on `Add New Connection`
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686662398364/448afb64-254d-4e9b-a61a-084438820d75.jpeg align="center")
    
* Select `MySQL` and fill as:
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686662998130/6e0d8547-66a8-475b-8bd7-329aa70c0a39.jpeg align="center")
    
* Click on `TEST CONNECTION` enter the password you set above while creating RDS
    
* You should get `Successfully connected!` message
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686663103689/dd5635c7-8c69-4775-88a2-0f66cfe673a2.jpeg align="center")
    
* Now Click on **<mark>SAVE CONNECTION </mark>** \-&gt; **<mark>CONNECT NOW</mark>**
    

**CONGRATULATIONS YOU HAVE SUCCESSFULLY CONNECTED WITH RDS**

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

# Thank you for LEARNING !!!
