Tips for postgreSQL and PHP

PHPCLI(Command Line Interface)からPostgreSQLに(localhostから)アクセスするための設定 (on Fedora7)

  • 設定ファイルいじる

/var/lib/pgsql/data/pg_hba.confの一番下の行の

# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

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

の部分を

# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

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

のように変更する。

  • 設定ファイル変更の後は、postgreSQLのサーバを再起動して設定を反映させることを忘れない。

/etc/init.d/postgresql restart

これで、localからのアクセスはtrustされ、アクセス可能となる。