ここに投稿された私の最初の質問。
現在、 VirtualBox 4.2.12で仮想化されたFedora 18を実行している同じマシンでPostgreSQL 9.01を実行しているUbuntu 12.04を搭載したラップトップを使用しています。
この仮想化された Fedora にはPostgreSQLクライアントがあり、Ubuntu で実行されている PostgreSQL サーバーに接続したいと考えています。
Ubuntuサーバー /etc/postgresql/9.1/main/postgresql.conf
上のファイルを編集して、接続を許可しました。
listen_addresses = '*'
また、同じ Ubuntu でファイル /etc/postgresql/9.1/main/pg_hba.conf を編集して、ユーザー postgres がデータベース テストに接続できるようにします。
local postgres test md5
しかし、Fedora から接続しようとすると、PgAdmin3 に次のエラー メッセージが表示されます。
Access to database denied
The server doesn't grant access to the database: the server reports
FATAL: no pg_hba.conf entry for host "192.168.1.239", user "postgres", database "jpa",
SSL on FATAL: no pg_hba.conf entry for host "192.168.1.239", user "postgres",
database "jpa", SSL off
To access a database on a PostgreSQL server, you first have to grant primary access
to the server for your client (Host Based Authentication).
PostgreSQL will check the pg_hba.conf file if a pattern that matches
your client address / username / database is present and enabled before any
SQL GRANT access control lists are evaluated.
The initial settings in pg_hba.conf are quite restrictive, in order to avoid
unwanted security holes caused by unreviewed but mandatory system settings.
You'll probably want to add something like host all all 192.168.0.0/24 md5
This example grants MD5 encrypted password access to all databases to all users
on the private network 192.168.0.0/24.
You can use the pg_hba.conf editor that is built into pgAdmin III
to edit the pg_hba.conf configuration file.
After changing pg_hba.conf, you need to trigger a server configuration reload
using pg_ctl or by stopping and restarting the server process.
私の pg_hba.conf は次のとおりです。
# Database administrative login by Unix domain socket
local all postgres peer
# 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 md5
host all all 10.0.2.15/16 md5
#local postgres postgres md5
#local postgres jpa md5
#local postgres test md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres peer
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5
10.0.2.15は仮想化された Fedora の IP です。
ありがとう!