LoginSignup
5
5

More than 5 years have passed since last update.

VPCを超えて、Elastic BeanstalkのMySQLサーバーに接続するメモ

Posted at

参考サイト

RDSにSSHのポートフォワーディングでMySQLに接続する方法 CakePHP編

手順

1.Key Pairを作成しておく

2.Elastic Beanstalk作成時に、Key Pairを指定しておく

3.EC2インスタンスに結びついているSecurity GroupのInboundタブで、ssh(22番)ポートを開けておく。

(SourceのところはMy IPを選ぶのがいいかも?)

4.sshのポートフォワーディング

$ ssh -f -N -L 3307:dev-ss.xxxxxxxxxxxx.ap-northeast-1.rds.amazonaws.com:3306 ec2-user@ec2-xxx-xxx-xxx-xxx.ap-northeast-1.compute.amazonaws.com -p 22 -i my-keypair-ec2user.pem
対応表
EC2のPublic DNS ec2-xxx-xxx-xxx-xxx.ap-northeast-1.compute.amazonaws.com
RDSのEndpoint dev-ss.xxxxxxxxxxxx.ap-northeast-1.rds.amazonaws.com
Key Pair my-keypair-ec2user.pem

5.好きなMySQLクライアントでlocalhost:3307に接続する

コンソールクライアントの場合:

$ mysql -u dbuser -p -h localhost --port=3307
5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5