AWS — RDS
What is RDS?
Managed relational database service supporting MySQL, PostgreSQL, Oracle, SQL Server.
Create database
aws rds create-db-instance \
--db-instance-identifier mydb \
--db-instance-class db.t2.micro \
--engine mysql \
--master-username admin \
--master-user-password password123 \
--allocated-storage 20
Connect
# Get endpoint
aws rds describe-db-instances \
--db-instance-identifier mydb \
--query "DBInstances[0].Endpoint.Address"
# Connect with MySQL
mysql -h mydb.xxxx.us-east-1.rds.amazonaws.com -u admin -p
Backup
# Create snapshot
aws rds create-db-snapshot \
--db-instance-identifier mydb \
--db-snapshot-identifier my-snapshot
# Restore from snapshot
aws rds restore-db-instance-from-db-snapshot \
--db-instance-identifier mydb-restored \
--db-snapshot-identifier my-snapshot
Scaling
# Scale vertically
aws rds modify-db-instance \
--db-instance-identifier mydb \
--db-instance-class db.t3.medium
# Scale storage
aws rds modify-db-instance \
--db-instance-identifier mydb \
--allocated-storage 100
Multi-AZ
aws rds modify-db-instance \
--db-instance-identifier mydb \
--multi-az
Read replicas
aws rds create-db-instance-read-replica \
--db-instance-identifier mydb-replica \
--source-db-instance-identifier mydb
Best practices
- Enable automated backups
- Use Multi-AZ for production
- Use read replicas for scaling
- Enable encryption
Mini Practice
- Create a MySQL database
- Connect and query
- Create a snapshot
- Enable Multi-AZ
Up Next
Continue with Lambda - Serverless Functions.
Related Topics
Frequently Asked Questions about RDS
What is RDS in AWS?
RDS is a fundamental concept in AWS. This lesson explains it step by step with clear examples, making it easy for beginners to understand.
How do I learn RDS?
Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn RDS.
Why is RDS important in AWS?
RDS is essential for AWS development. Understanding this concept will help you write better code and solve real-world problems more effectively.