Overview
You will:
deploy a Lightsail MySQL database instance
deploy a Lightsail Ubuntu instance
connect the Ubuntu instance to the database instance
create additional users and databases on the database instance
enable logging and snapshots of the database instance
Prerequisites
To begin with, you just need an AWS Account
Service we will be using : AWS LightSail
Let's get started
Create a Database server
Switch to the Databases
tab and then click Create database
You will see the below screen for your Database creation
Select your Database location
as your nearest location.
then Pick your database
as MySQL with the latest version.
Scroll down to give your database a master user.
Choose Specify login credentials
Create a user with a name dbmaster
and Specify a password as Hello2World
Give your Database a Name dbmain
Choose your Database plan
here $15
is selected by default just keep it unchanged
Give your Database Instance a name
Then click on Create database
to deploy your Database Instance.
Create Instances
Go back to Home and choose the tab Instances
Create an Instance and deploy it on the same Region as of Database
Select Platform as Linux/Unix
Select a blueprint type OS Only
and select Ubuntu
Scroll down to add Launch Script
sudo apt update
sudo apt-get install mysql-client-core-8.0 -y
As shown below,
Keep the Instance Plan
as Default $3.5
To identify your instance add Ubuntu-1
Then click on Create Instance
and you are Done!!
Click console icon in orange color
on Ubuntu Instance near 3 dot
Yow will be directed to a new window as a Console
SSH into the Database Instance with below command,
mysql -h DATABASE_URL -u dbmaster -pHello2World
Replace DATABASE_URL with your Database endpoint as show in below yours will be a different endpoint
Once you SSH into Database Instance you can create, delete, drop, truncate the Database and tables.
Run the this command to view your Databases
SHOW DATABASES;
Create a new Database named as secondDB
CREATE DATABASE secondDB;
Give your user dbmaster
privileges using this command,
GRANT ALL PRIVILEGES ON secondDB.* TO 'dbmaster'@'%';
It Grants all the privileges on the secondDB database
Now exit the session and terminate all the instance we created for saving from unwanted AWS bill.
exit
Finally we are have successfully Configured and deployed MySQL Database
Conclusion
Congratulations on deploying and configuring your Lightsail database instance. You should now feel comfortable using Lightsail databases to power any applications you build or deploy on Lightsail.