Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issues while connecting psql

I installed postgresql in accordance with the instructions given at: http://xadmin.info/?p=284

# pg_ctl -D /var/lib/pgsql/data -l pglog.log start
server starting
postgres@linux-p0pl:~> psql
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"?

I am not getting as to why am I getting this error when the server has started...can someone please please help.

My pglog.log file shows the following output:

2013-02-06 19:43:39 GMT   FATAL:  lock file "postmaster.pid" already exists
2013-02-06 19:43:39 GMT   HINT:  Is another postmaster (PID 23971) running in data directory "/var/lib/pgsql/data"?
2013-02-06 19:44:02 GMT   FATAL:  lock file "postmaster.pid" already exists
2013-02-06 19:44:02 GMT   HINT:  Is another postmaster (PID 23971) running in data directory "/var/lib/pgsql/data"?
2013-04-24 12:43:29 GMT   FATAL:  data directory "/var/lib/pgsql/data" has group or world access
2013-04-24 12:43:29 GMT   DETAIL:  Permissions should be u=rwx (0700).
2013-04-24 12:44:07 GMT   FATAL:  data directory "/var/lib/pgsql/data" has group or world access
2013-04-24 12:44:07 GMT   DETAIL:  Permissions should be u=rwx (0700).
2013-04-24 12:57:02 GMT   FATAL:  data directory "/var/lib/pgsql/data" has group or world access
2013-04-24 12:57:02 GMT   DETAIL:  Permissions should be u=rwx (0700).
2013-04-24 12:57:40 GMT   FATAL:  data directory "/var/lib/pgsql/data" has group or world access
2013-04-24 12:57:40 GMT   DETAIL:  Permissions should be u=rwx (0700).

ps -ef | grep postgres

root     21659 21591  0 19:14 pts/0    00:00:00 grep --color=auto postgres
like image 616
user1778824 Avatar asked Apr 24 '13 13:04

user1778824


3 Answers

The permissions and ownership on /var/lib/pgsql/data should be:

# ll -d /var/lib/pgsql/data
drwx------. 15 postgres postgres 4096 Apr 24 10:27 /var/lib/pgsql/data

If they are not do as root:

# chmod -R 700 /var/lib/pgsql/data
# chown -R postgres /var/lib/pgsql/data
like image 57
Clodoaldo Neto Avatar answered Oct 01 '22 20:10

Clodoaldo Neto


Check in the pglog.log file to ensure that the server did actually start without error. Given the error it seems like it did not start properly.

like image 30
Ed Plese Avatar answered Oct 01 '22 22:10

Ed Plese


You probably don't have your server configured to put unix domain sockets in "/tmp". It's probably somewhere like "/var/run/pgsql" but see your postgresql.conf file to see exactly what.

Then you can specify this directory as a "host" on the command-line:

psql -h /path/we/want ...

If that's not the problem, check the port number.

Not sure why/how your psql client and postgresql server have different default paths, but then I've never heard of the site you got the instructions from, so I've no idea how useful they are.

like image 40
Richard Huxton Avatar answered Oct 01 '22 21:10

Richard Huxton