DEV Community

Yash Sonawane
Yash Sonawane

Posted on

Step-by-Step: Set Up Your First RDS MySQL/PostgreSQL Database πŸ› οΈπŸ“¦

β€œDo I need to install MySQL on my EC2 to build a database?” Nope. AWS RDS does the heavy lifting for you β€” and it’s easier than you think.

In this guide, we’ll walk through hosting a production-ready MySQL or PostgreSQL database on Amazon RDS, fully managed, scalable, and beginner-friendly.


☁️ What is Amazon RDS?

Amazon RDS (Relational Database Service) is a cloud-based, fully managed database service.

βœ… Why Use RDS Instead of Installing DB Manually?

  • No manual setup or updates
  • Automated backups and monitoring
  • Scales easily (vertically + replicas)
  • Connect securely from your app or EC2

Real-world analogy: RDS is like renting a premium coffee machine. You just push a button to brew (run queries), and AWS handles water, filters, cleaning (infrastructure).


🧰 Prerequisites

  • AWS Free Tier account (PostgreSQL/MySQL are included)
  • Basic familiarity with EC2 or terminal
  • A client like MySQL Workbench or DBeaver (optional)

πŸš€ Step 1: Launch Your RDS Instance

1. Go to AWS Console β†’ RDS

2. Click β€œCreate Database”

  • Engine Type: MySQL or PostgreSQL
  • Templates: Choose Free Tier
  • DB Instance Identifier: mydb
  • Master Username: admin
  • Master Password: StrongPassword123

3. Configure Instance

  • Instance type: db.t3.micro
  • Storage: 20GB (default, free tier)
  • Enable Storage Autoscaling: βœ…

4. Connectivity

  • VPC: Default or your custom VPC
  • Public Access: Enable if connecting externally (or disable for internal only)
  • VPC Security Group: Add rule to allow port 3306 (MySQL) or 5432 (PostgreSQL)

πŸ•’ Step 2: Wait for the DB to Be Ready

It usually takes 5–10 minutes. Grab a coffee β˜•

Once the DB is Available, note the Endpoint β€” it’s your database URL.

Example:

mydb.abc123xyz.us-east-1.rds.amazonaws.com
Enter fullscreen mode Exit fullscreen mode

πŸ”Œ Step 3: Connect to Your RDS Instance

Option A: From Your Local PC (if Public Access Enabled)

Using MySQL:

mysql -h mydb.abc123xyz.us-east-1.rds.amazonaws.com -P 3306 -u admin -p
Enter fullscreen mode Exit fullscreen mode

Using PostgreSQL:

psql -h mydb.abc123xyz.us-east-1.rds.amazonaws.com -U admin -d postgres
Enter fullscreen mode Exit fullscreen mode

Enter your password when prompted.

Option B: From EC2 (Preferred for security)

SSH into your EC2 instance and use the same commands from above.


πŸ’‘ Step 4: Create Tables and Use Your DB

Once connected, you can create databases, tables, and more.

-- For MySQL or PostgreSQL
CREATE DATABASE myapp;
USE myapp;
CREATE TABLE users (
  id INT PRIMARY KEY AUTO_INCREMENT,
  name VARCHAR(100),
  email VARCHAR(100)
);
Enter fullscreen mode Exit fullscreen mode

You’re now running a live production-grade DB on AWS! πŸŽ‰


πŸ›‘ Pro Tips and Best Practices

  • βœ… Use private subnets for DB (no public access in prod)
  • πŸ” Enable IAM authentication for stronger access control
  • ♻️ Turn on automated backups
  • πŸ›‘ Set up deletion protection so you don’t delete by mistake
  • πŸ“Š Enable CloudWatch monitoring for performance insights

πŸ”„ Bonus: How to Connect Your App to RDS

In your backend app (Node.js, Python, etc.), just use the RDS endpoint as your host:

// Node.js example
const mysql = require('mysql');
const connection = mysql.createConnection({
  host: 'mydb.abc123xyz.us-east-1.rds.amazonaws.com',
  user: 'admin',
  password: 'StrongPassword123',
  database: 'myapp'
});
Enter fullscreen mode Exit fullscreen mode

And boom β€” you're hooked up!


🧠 Recap

Step What You Did
1️⃣ Launched an RDS MySQL/PostgreSQL instance
2️⃣ Configured security + storage settings
3️⃣ Connected using terminal or GUI tool
4️⃣ Created your first DB and table

Whether it’s for a portfolio project, startup MVP, or school assignment β€” you now have a fully managed cloud DB up and running. πŸ™Œ


πŸ’¬ What’s Next?

Want to scale your DB with replicas? Automate failovers? Use RDS Proxy for Lambda?

πŸ‘‡ Drop your questions in the comments, hit ❀️ if this made RDS less scary, and share it with someone starting their cloud journey!

Let’s keep building β€” one block at a time. 🧑

Top comments (1)

Collapse
 
heatherp profile image
heather

very helpful!