Creating RDS database
Step 1: Create Database
- Goto RDS dashboard and click on Create Database
- Select Standard create for database creation method
- I chose MariaDB engine
- Engine Version selected n-1 that is one step behind the latest one
- Select Free Tier Template
- I leave database-1 as DB instance identifier name
- Self Managed Credential Management
- and inputed desired Master Password i.e
Passw0rd123
- In instance configuration I selected Burstable classes for DB instance class
- and selected db.t3.micro
- for storage I selected General Purpose SSD gp2 and allocated 20GB of storage
- I left default setting as it is and clicked on Create Database
Step 2: Configure Instance for Mariadb
- Launch ec2 instance
- I gave name of ec2 instance db-test
- Selected Amazon linux free tier
- and added security group for 3306 port [make sure to have same security group for both ec2 and rds]
- Clicked on create instance
- Log into instance
Step 3: Connect to RDS via ec2
- After login to ec2 install mariadb client
yum install mariadb105
- Login to endpoint of RDS we just created
mysql -h <hostname> -u <user> -p
mysql -h database-1.czsumoyo8fx5.us-west-2.rds.amazonaws.com -u admin -p
Input the password and congrats you just logged into your fresh sql database.
Scratchpad
HA - high availability n-1 3306 maridb sql sudo yum list installing mariadb client yum install mariadb105
diagram default vpc 3 public subnet 1 subnet ⇒ ec2 2 subnet ⇒ rds endpoint access mysql -h
-u -p>
create database demo;
show database;
use demo;
drop database demo;
CREATE TABLE Persons (
PersonID int,
LastName varchar(255),
FirstName varchar(255),
Address varchar(255),
City varchar(255)
);
desc Persons;
Insert Into Persons (PersonID, LastName, FirstName) values (1, "DemoName", "Amir");
select * from Persons;
https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql
1. CREATE USER ' ==sammy=='@'localhost' IDENTIFIED BY '==password==';
grant create , alter drop insert update delete select on demo.persons to sammy@&;
grant select on demo.* to "sammy"@"%";
show grants for
install tomcat
build application
create user
CREATE USER 'sammy'@'localhost' IDENTIFIED BY 'password';
show user
SELECT User, Host FROM mysql.user;