Skip to content

Commit

Permalink
AWS RDS Masterclass Commands
Browse files Browse the repository at this point in the history
AWS RDS Masterclass Commands
  • Loading branch information
yeshwanthlm authored Sep 23, 2022
1 parent 090d571 commit e600bd8
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions aws-rds-masterclass.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# AWS RDS Masterclass Commands

## Databases on EC2 Instance - Demo
### Begin Configuration :
```bash
yum -y install mariadb-server wget
systemctl enable mariadb
systemctl start mariadb
yum -y update
```
### Set Environmental Variables
```bash
DBName=ec2db
DBPassword=admin123456
DBRootPassword=admin123456
DBUser=ec2dbuser
```
### Database Setup on EC2 Instance:
```bash
echo "CREATE DATABASE ${DBName};" >> /tmp/db.setup
echo "CREATE USER '${DBUser}' IDENTIFIED BY '${DBPassword}';" >> /tmp/db.setup
echo "GRANT ALL PRIVILEGES ON *.* TO '${DBUser}'@'%';" >> /tmp/db.setup
echo "FLUSH PRIVILEGES;" >> /tmp/db.setup
mysqladmin -u root password "${DBRootPassword}"
mysql -u root --password="${DBRootPassword}" < /tmp/db.setup
rm /tmp/db.setup
```
### Adding some dummy data to the Database inside EC2 Instance:
```bash
USE ec2db;
CREATE TABLE table1 (id INT, name VARCHAR(45));
INSERT INTO table1 VALUES(1, 'Virat'), (2, 'Sachin'), (3, 'Dhoni'), (4, 'ABD');
SELECT * FROM table1;
```
### Migration of Database in EC2 Instance to RDS Database:
```bash
mysqldump -u root -p ec2db > ec2db.sql
mysql -h <replace-rds-end-point-here> -P 3306 -u rdsuser -p
CREATE DATABASE rdsdb;
mysql -h <replace-rds-end-point-here> -P 3306 -u rdsuser -p rdsdb < ec2db.sql
USE rdsdb
SELECT * FROM table1;
```



0 comments on commit e600bd8

Please sign in to comment.