Randell's Tech Blog

Randell's Tech Blog


PostgreSQL notes

Posted: 13 Nov 2009 01:20 AM PST

This is just another one of my notes. I often encounter these errors after a fresh install of Fedora.

After executing

psql -U postgres

and getting this message:

psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket “/tmp/.s.PGSQL.5432″?


It could mean that the postgresql service has not been started (and it could also mean some other things that I haven’t encountered yet). So to start the database, execute the following commands as root:

Initialize the database

service postgresql initdb

Start the PostgreSQL service

/etc/init.d/postgresql start

Then, if I get this message:

psql: FATAL:  Ident authentication failed for user "postgres"

it means I need to edit the last few lines of /var/lib/pgsql/data/pg_hba.conf (this file controls: which hosts are allowed to connect, how clients are authenticated, which PostgreSQL user names they can use, which databases they can access) to look like this:

# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD  # "local" is for Unix domain socket connections only 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

The change is with the line containing the local connection type, whose method is changed from ident to trust

Then restart the PostgreSQL service:

/etc/init.d/postgresql restart

Related posts:

  1. PostgreSQL restore and dump

Tags:

0 comments: