Configuring EC2 instance with MobaXterm

install MobaXterm and connecting the EC2 instance

  1. click on this link to install MobaXterm
  2. after installing MobaXterm click on session role
  3. add the paste the public ip address that we copy into the remote host
  4. specify the user name as ec2-user
  5. then select the .pem key that we downloaded
  6. click ok role
  7. we now access our linux easy 2 instance role

configuring database in EC2

  1. this code will install the mariadb SQL database server in the ec2 instance
sudo su -
yum -y install mariadb-server wget
systemctl enable mariadb
systemctl start mariadb
yum -y update

role

  1. then set the environment variable of all including the name of our database , the DBPassword , the DBRootPassword , the database user name
DBName=ec2db
DBPassword=admin123456
DBRootPassword=admin123456
DBUser=ec2dbuser

role 3. set up the database

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

role 4. then add some data to test out our instance

mysql -u root --password="${DBRootPassword}"
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;

role It will now out put us the table that we created using mariadb-server