3
7

More than 3 years have passed since last update.

RDS(PostgreSQL)の接続方式について

Last updated at Posted at 2020-06-22

1.目的

RDS(PostgreSQL)をAmazon Linux2より接続する手順を説明します。RDSへはpsql コマンドラインを使用して、PostgreSQL DB インスタンスに接続できます。PostgreSQL またはクライアントコンピュータにインストールされた psql クライアントのどちらかを利用します。psql を使用して PostgreSQL DB インスタンスに接続するには、ホスト情報とアクセス認証情報を指定する必要があります。

2.手順

postgreSQLのダウンロード手順

インストール手順
sudo yum -y install postgresql.x86_64
postgresql12をインストールしたいかたはこちら
rpm -ivh --nodeps https://download.postgresql.org/pub/repos/yum/12/redhat/rhel-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sed -i "s/\$releasever/7/g" "/etc/yum.repos.d/pgdg-redhat-all.repo"
yum install -y postgresql12
yum install -y postgresql12-server
yum install -y postgresql12-contrib

pgslでの接続手順

pgqlでの接続方法
psql \
   --host=<DB instance endpoint> \
   --port=<port> \
   --username=<master user name> \
   --password \
   --dbname=<database name> 
pgqlコマンドの接続結果
Password for user postgres: 
psql (9.2.24, server 11.6)
WARNING: psql version 9.2, server version 11.0.
         Some psql features might not work.
SSL connection (cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256)
Type "help" for help.
postgres-> 
3
7
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
3
7