ペチパーノート

WEB開発系Tipsブログです。

~AWSでLAMP環境を作る~ その10 EC2からRDSに接続する

EC2にMySQLをインストールし、ホスト指定してRDSに接続してみます。

手順

MySQLインストール

# yum install mysql-server

起動

# service mysqld start

自動起動設定

# chkconfig mysqld on

接続
mysql -u {RDSのエンドポイント} -u {ユーザー名} -p{パスワード}

# mysql -h mydb.xxxxxxxx.ap-northeast-1.rds.amazonaws.com -u admin -pxxxxxxx

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 75
Server version: 5.6.13-log MySQL Community Server (GPL)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| fufufu             | ←RDS作成時に指定したDBが作成されています
| innodb             |
| mysql              |
| performance_schema |
+--------------------+
5 rows in set (0.13 sec)

無事接続できました!!

エンドポイントってなんだっけ?となった時は↓です

f:id:butterbull:20140614004632j:plain