Introduction
Amazon Aurora is a fully managed relational database service from AWS, compatible with MySQL and PostgreSQL. It delivers up to 5 times better performance than standard MySQL while ensuring 99.99% high availability. In 2026, with Aurora Serverless v2 and native AI/ML integration, it's essential for scalable apps like SaaS, e-commerce, or microservices.
Why choose Aurora? Picture a database that auto-scales (from 0.5 to 128 ACU), replicates data across 6 copies in 3 AZs with zero downtime, and recovers in 30 seconds after a crash. This intermediate tutorial walks you through deploying an Aurora MySQL cluster via AWS CLI, configuring it, loading SQL data, monitoring, and optimizing. At the end, you'll have a production-ready DB—bookmark it for your AWS projects!
Prerequisites
- Active AWS account with IAM permissions for RDS (AmazonRDSFullAccess)
- AWS CLI v2 installed and configured (
aws configurewith access key/secret) - MySQL client installed locally (
brew install mysqlon macOS or equivalent) - AWS region: us-east-1 (modifiable in commands)
- Basic SQL and VPC knowledge (Aurora requires a subnet group)
Create the DB Subnet Group
aws rds create-db-subnet-group \
--db-subnet-group-name aurora-tutorial-subnet \
--db-subnet-group-description "Subnet group pour Aurora tutorial" \
--subnet-ids subnet-0123456789abcdef0 subnet-0123456789abcdef1 subnet-0123456789abcdef2 \
--region us-east-1This command creates the required DB Subnet Group for Aurora, specifying 3 subnets in different AZs (replace with your VPC IDs). Without it, cluster creation fails. Check your subnets with aws ec2 describe-subnets; they should be private for security.
Step 1: Network Preparation
Aurora runs in a VPC. The subnet group spreads replicas across multiple Availability Zones for resilience. Run the command above and verify with aws rds describe-db-subnet-groups --db-subnet-group-name aurora-tutorial-subnet. Time: ~1 min.
Create the Aurora MySQL Cluster
aws rds create-db-cluster \
--db-cluster-identifier aurora-tutorial-cluster \
--engine aurora-mysql \
--engine-version 8.0.mysql_aurora.3.05.0 \
--master-username admin \
--master-user-password SecurePass123! \
--db-subnet-group-name aurora-tutorial-subnet \
--storage-encrypted \
--region us-east-1Creates an Aurora MySQL 8.0 cluster with encryption enabled and a strong password (change it!). The engine-version is the latest in 2026 for optimal performance. The cluster is primary-ready but without a writer instance yet.
Add a Writer Instance to the Cluster
aws rds create-db-instance \
--db-instance-identifier aurora-tutorial-writer \
--db-instance-class db.r6g.large \
--engine aurora-mysql \
--db-cluster-identifier aurora-tutorial-cluster \
--region us-east-1Adds the primary (writer) instance to the cluster using db.r6g.large (balanced cost/performance). Aurora auto-generates 5 read replicas. Wait 5-10 min and check with aws rds describe-db-instances --db-instance-identifier aurora-tutorial-writer.
Step 2: Launch the Cluster
After creation, note the cluster endpoint via aws rds describe-db-clusters --db-cluster-identifier aurora-tutorial-cluster (e.g., aurora-tutorial-cluster.cluster-abc123.us-east-1.rds.amazonaws.com:3306). This is your single entry point for HA.
Connect and Create a Database
mysql -h aurora-tutorial-cluster.cluster-abc123.us-east-1.rds.amazonaws.com -P 3306 -u admin -pSecurePass123! <<< "CREATE DATABASE tutorial_db; USE tutorial_db; SHOW DATABASES;"Connect to the cluster endpoint (replace with yours) and create tutorial_db. The <<< runs SQL in one line. Test the connection; if it times out, check Security Group (port 3306 inbound from your IP).
Create Tables and Insert Data
USE tutorial_db;
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
email VARCHAR(255) UNIQUE NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
INSERT INTO users (name, email) VALUES
('Alice', 'alice@example.com'),
('Bob', 'bob@example.com'),
('Charlie', 'charlie@example.com');
SELECT * FROM users;
CREATE INDEX idx_email ON users(email);Creates a users table with an index for query performance. Inserts 3 rows and verifies. Copy-paste into the mysql client. Aurora auto-optimizes indexes for scalable reads.
Step 3: Data and Schemas
Run schema.sql via mysql ... < schema.sql. Aurora handles ACID transactions; test with SELECT COUNT(*) FROM users to confirm.
Enable Auto-Scaling (Serverless v2)
aws rds modify-db-instance \
--db-instance-identifier aurora-tutorial-writer \
--engine aurora-mysql \
--scaling-config MinCapacity=1,MaxCapacity=16,AutoPause=true,SecondsUntilAutoPause=300 \
--region us-east-1Converts to Serverless v2: scales from 1-16 ACU, auto-pauses after 5 min of inactivity (cost-saving). Ideal for variable workloads. Apply and test load with sysbench.
Configure Backups and Monitoring
aws rds modify-db-cluster \
--db-cluster-identifier aurora-tutorial-cluster \
--backup-retention-period 7 \
--preferred-backup-window 03:00-04:00 \
--cloudwatch-logs-export-configuration '{ "EnableLogTypes": ["error", "slowquery"] }' \
--region us-east-1
aws cloudwatch put-metric-alarm \
--alarm-name HighCPU \
--metric-name CPUUtilization \
--namespace AWS/RDS \
--statistic Average \
--period 300 \
--threshold 80 \
--comparison-operator GreaterThanThreshold \
--dimensions Name=DBInstanceIdentifier,Value=aurora-tutorial-writer \
--evaluation-periods 2 \
--alarm-actions arn:aws:sns:us-east-1:123456789012:NotifyMe \
--region us-east-1Enables 7-day backups + CloudWatch logs. Creates a CPU >80% alarm notifying via SNS (create the topic ARN first). Aurora PITR recovers in <1 min.
Step 4: Advanced Optimization
Track CPU and IOPS metrics in CloudWatch (Aurora IO-optimized is free). Add read replicas: aws rds create-db-instance --db-instance-class db.r6g.large --... --promotion-tier 1.
Best Practices
- Always encrypt: Use KMS for data-at-rest and TLS for transit.
- Use cluster endpoint: Avoid instance endpoints for auto-failover.
- Custom Parameter Groups: Tune
max_connections=1000,innodb_buffer_pool_sizefor performance. - IAM Database Auth: Skip passwords with temporary tokens.
- Performance Insights: Enable for top slow queries (free for 7 days).
Common Errors to Avoid
- Forget Security Group: Port 3306 blocked → connection timeout.
- Public subnets: Aurora rejects them; use private + NAT Gateway.
- Weak password: Change post-creation via
aws rds modify-db-cluster. - Ignore costs: Serverless auto-pauses; monitor ACU with AWS Budgets.
Next Steps
- AWS Docs: Aurora MySQL
- Migrate from MySQL:
aws dms create-replication-instance - Serverless Data API: HTTP queries without a DB client.
- Check out our AWS training courses for Architect certification.