Add Database for Testing

Preparation

To ensure the application works, we need to load data into the RDS instance.

We will use the SQL script in aws-fcj-container-app/database to insert the data. To do this, first navigate to the aws-fcj-container-app/database directory to get the script path:

cd aws-fcj-container-app/database
echo $PWD/init.sql

5.3.1.png

Copy the path as we will use it later.

Connect to RDS

Now, we’ll use the MySQL client installed earlier to connect to the RDS instance. First, go to the RDS Console:

  • Select the RDS instance you created earlier.
  • Copy the endpoint.

5.3.2.png

Use the following command to connect:

mysql -h "rds-endpoint" -u admin -p

5.3.3.png

Next, we will use the source /home/ubuntu/aws-fcj-container-app/database/init.sql command to run the SQL script. Paste the script path copied earlier and execute the command.

5.3.4.png

Verify Results

Check the database: SHOW DATABASES

5.3.5.png

Check the data: USE fcjresbar then SELECT * FROM fcjresbar

5.3.6.png