To connect to the EC2 Instance is pretty easy and we will access the RDS SQL through EC2 instance. We will also perform basic operations like Create Database, Create Table, Insert data on RDS.
Go to Terminal window on Mac
Connect to the EC2 Instance by clicking connect and use the preferred method of connecting.
Note: For this Demo we will be connecting to EC2 instance using ssh, How to connect commands should be made available to users upon clicking connect option.
On the Terminal window Navigate to the location where the Key pair for instance was downloaded (Demo Key is located in the Downloads folder)
Command to Navigate to the folder
cd ~/downloads
Command to locate the exact file in download
ls -l dbtest01.pem
We will follow the ssh instruction shown in the first image.
chmod 400 dbtest01.pem
We will now copy the Example command and paste in our terminal to connect to EC2 Instance.
Once we are connected to the instance, we will run update command to update the OS.
sudo apt update
Installation of SQL client is also required on EC2 Instance.
sudo apt install mysql-server
In order to connect to the mysql we will need it’s Endpoint & Port, you can find it by clicking on the database “dbtest01” and navigating to the connectivity and security.
Command we will be using to connect to the “dbtest01”
mysql --user=admin --password=123456789 -h dbtest01.cbb65prupaef.us-east-1.rds.amazonaws.com
Once you see the following message it means that you are in mysql RDS
My SQL database creation, creating table, inserting data
MySQL Commands
SHOW DATABASE;
Will show the existing databases in mysql
CREATE DATABASE staff;
Will create a database for staff
CREATE TABLE employees (name VARCHAR(20), department VARCHAR(20), jobtitle VARCHAR(20), sex CHAR(1), startdate DATE, enddate DATE);
Will create table with employees data
SHOW TABLES;
Will show the table employees.
DESCRIBE employees;
Will show the data inside the table
For more useful commands you can reference it to W3Schools MySQL Guide
Comments
Post a Comment