AWS RDS Tutorial for Beginners: Launch MySQL and Connect from Terminal

A relational database stores data in tables with rows and columns. Example: a products table with columns like id, name, description, price, and stock. These tables can be related using keys. Popular relational databases include MySQL, PostgreSQL, Oracle, MariaDB, and SQL Server.

When deploying applications (for example on EC2), they typically need one of these relational databases to store application data.


What is AWS RDS?

Amazon RDS (Relational Database Service) is a managed database service that allows you to create, operate, and scale relational databases without managing the underlying servers.

RDS automatically handles:

  • Provisioning
  • Backups
  • Patching
  • Monitoring

Supported engines:

  • Amazon Aurora (MySQL/PostgreSQL compatible)
  • MySQL
  • PostgreSQL
  • MariaDB
  • Oracle
  • Microsoft SQL Server
  • IBM Db2

You connect to RDS databases using normal CLI tools or JDBC URLs.


Create an RDS MySQL Database (Free Tier)

  • Open the RDS Console → Click Create database
  • Choose Standard create
  • Engine: MySQL Community Edition
  • Choose a MySQL version
  • Template: Free tier

Free Tier allows:

  • Single AZ instance
  • db.t4g.micro instance
  • 20 GB GP3 storage

Configuration:

  • DB identifier: database-1
  • Master username: admin
  • Password: admin1234 (example)
  • Instance class: db.t4g.micro

Connectivity & Security Settings

  • Public access: Yes (only for learning/demo)
  • VPC security group: allow port 3306 from your IP
  • Authentication: Password authentication
  • Monitoring: basic (free tier)

Click Create database. The instance will take a few minutes to become available.


Viewing RDS Instance Details

Once available, open the DB instance page. You will see:

  • Status: available
  • Engine: MySQL
  • AZ: e.g., ap-south-1a
  • Endpoint: used for connecting
  • Port: 3306

The endpoint is the hostname you use in your MySQL CLI or JDBC.


Connect to AWS RDS MySQL from Terminal

Install MySQL client:

  • macOS → Homebrew
  • Windows → MySQL Installer

Connect using:


mysql -h <endpoint> -P 3306 -u admin -p

Example:


mysql -h database-1.xxxxx.ap-south-1.rds.amazonaws.com -P 3306 -u admin -p

Enter your password when prompted.

Inside the MySQL shell:


SHOW DATABASES;
CREATE DATABASE demo_db;
USE demo_db;

CREATE TABLE employees (
  id INT PRIMARY KEY,
  name VARCHAR(100),
  salary INT
);

INSERT INTO employees VALUES (1, 'John', 50000);
SELECT * FROM employees;

Cleaning Up (Delete RDS Instance)

  • Go to RDS Console
  • Select your DB instance
  • Click Delete
  • Skip final snapshot (demo purpose)
  • Confirm deletion phrase

Status becomes deleting and then the instance disappears.

Any future connection attempts to the old endpoint will fail.


Summary

AWS RDS allows you to launch relational databases like MySQL without managing servers. You still connect and execute SQL exactly as you would with a local database. In the next step, this same RDS instance can be integrated with Spring Boot using normal JDBC URLs.


Comments

Popular posts from this blog

Spring Boot on AWS EC2: Upload to S3 Securely Using IAM Role

Java Streams Intermediate Operations Explained with Examples

ConcurrentHashMap vs Synchronized HashMap in Java