私は、pg_hba.confファイルの設定が非常に難しいことを発見しました。ここに私の時間を無駄にする一般的なケースがあります。私は何をする必要がありますか?データベースの役割を果たすために、在庫pg_hba.confファイルにはどのような権限が必要ですか?
まず、Amazon、Digital Ocean、または自分のハードウェアに新しくインストールされたLinuxディストリビューションで仮想マシンをセットアップします。私は通常のFedoraやCentOSのを使用して、このメソッドを介してのPostgresを取得:
rpm -Uvh http://yum.postgresql.org/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm
yum install postgresql96 postgresql96-server postgresql96-contrib postgresql96-devel -y
/usr/pgsql-9.6/bin/postgresql96-setup initdb
systemctl enable postgresql-9.6
systemctl start postgresql-9.6
echo export PATH=/usr/pgsql-9.6/bin:"$PATH" >> /etc/profile.d/postgresql96.sh
yum update -y
ただ、ファイアウォールに穴をポップ、いくつかのことを除外するために(これはDEVである - それはOKです)
firewall-cmd --permanent --add-port=5432/tcp
firewall-cmd --reload
編集/var/lib/pgsql/9.6/data/postgresql.conf
データベースユーザー
su postgres
createuser --interactive -W bob
<answer yes to make bob a superuser>
psql
ALTER USER bob PASSWORD 'whatever';
を作成し、変更
#listen_addresses = 'localhost'
に
listen_addresses = '*'
0123物事は常に横向きに行くところ
再起動
systemctl restart postgresql-9.6
は今、ここにあります。
su postgres
psql -U bob -W
<enter password>
psql: FATAL: Ident authentication failed for user "bob"
私はpg_hba.confで何かする必要があることを知っていますが、そこに書き込むものは何ですか?私はこれを試してみました
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 ident
# IPv6 local connections:
host all all ::1/128 ident
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres peer
#host replication postgres 127.0.0.1/32 ident
#host replication postgres ::1/128 ident
:デフォルトでは、この言う
host all bob all md5
をしかし、それは動作しません。
私は
host all bob all ident
を試みたしかし、それは動作しません。
リモートボックスからTCP/IP経由でpgadmin3に接続しようとしましたが、どちらも動作しません。ローカルでは動作しません。
最後に、ローカルでpobadmin3を介してリモートからログインできるようにしたいと考えています。
UPDATE:いくつかの典型的なユースケースのためにpg_hba.confファイルをセットアップする方法についてはっきりと説明しているWebページはありますか?
'all 'がIPアドレスフィールドで受け入れられているのとは別に、デフォルトのUnixの代わりに' psql -U bob -W'がTCP/IP接続を試みる( 'PGHOST'変数? -domainソケット接続であり、 'peer' authメソッドは' ident'ではなく、選択されるべきです。 –