Amazon RDS (Relational Database Service)を構築していきます。
Amazon Relational Database Service (Amazon RDS) は、AWS クラウド でリレーショナルデータベースを簡単にセットアップし、運用し、スケーリングすることのできるウェブサービス
https://docs.aws.amazon.com/ja_jp/AmazonRDS
〜〜Amazon RDSの作成〜〜
1.検索ボックスで”rds”を検索し”Aurora and RDS”をクリック

2.”DB インスタンス”をクリック

3.”データベースの作成”をクリック

4.必要情報を入力し、”データベースの作成”をクリック














〜〜作成したMySQLデータベースの接続情報の取得〜〜
5.”接続の詳細の表示”をクリック

6.表示される”マスターパスワード”と”エンドポイント”を控えて、閉じるをクリック

7.ステータスが”利用可能”となるまで待つ(約5分程度)

↓

〜〜Amazon RDSとEC2間のセキュリティグループの修正〜〜
8.作成したDBをクリック

9.VPCセキュリティグループ”rds-sg”をクリック

10.セキュリティグループID”sg-xxxx”をクリック

11.”インバウンドのルールを編集”をクリック

12.”削除”をクリック

13.”ルールを追加”をクリック

14.必要情報を入力し、”ルールを保存”をクリック


15.ステップ2:Amazon EC2の構築で作成したEC2にてRDSへ接続確認
mysql -u <db_user_name> -p -h <db_hostname>
[ec2-user@ip-172-31-10-231 ~]$ mysql -u admin -p -h demodb-374567775469.cdu44iq4kgoj.ap-northeast-1.rds.amazonaws.com
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 38
Server version: 8.0.40 Source distribution
Copyright (c) 2000, 2025, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>