さくらVPSにPostgresqlをインストール

さくらVPSPostgresqlをインストールした時のメモ

# yum update -y
# yum install -y https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm
# yum install -y postgresql96-server postgresql96-contrib postgresql96-devel
# psql --version
psql (PostgreSQL) 9.6.11

初期化

# export PGSETUP_INITDB_OPTIONS="--encoding=UTF-8 --no-locale"
# /usr/pgsql-9.6/bin/postgresql96-setup initdb
# systemctl enable postgresql-9.6
# systemctl start postgresql-9.6

認証方法を変更

$ sudo vim /var/lib/pgsql/9.6/data/pg_hba.conf

peerをtrustに、identをmd5に変更

# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5

参考