0

我有 postgres 服务器在我的机器上本地运行。更新并重新启动后,我似乎无法运行它。

$ 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"?

$ pg_ctl start -D /Library/PostgreSQL/9.1/data/
pg_ctl: could not open PID file "/Library/PostgreSQL/9.1/data/postmaster.pid": Permission denied

$ sudo ls /Library/PostgreSQL/9.1/data/
PG_VERSION  global      pg_hba.conf pg_log      pg_notify   pg_stat_tmp pg_tblspc   pg_xlog     postmaster.opts
base        pg_clog     pg_ident.conf   pg_multixact    pg_serial   pg_subtrans pg_twophase postgresql.conf postmaster.pid

显然服务器正在运行。

$ ps aux | grep postmaster
postgres    63   0.0  0.0  2480820   7320   ??  Ss    4:39PM   0:00.27 /Library/PostgreSQL/9.1/bin/postmaster -D/Library/PostgreSQL/9.1/data
xxxxx      636   0.0  0.0  2435116    524 s000  R+    5:22PM   0:00.00 grep postmaster

我不是 data/ 的所有者,postgres 是:

$ ls -alth /Library/PostgreSQL/9.1/data/
ls: : Permission denied
$ sudo ls -alth /Library/PostgreSQL/9.1/data/
Password:
total 88
drwx------   3 postgres  daemon   102B Jan 24 20:04 pg_stat_tmp
drwx------  42 postgres  daemon   1.4K Jan 24 16:41 global
drwxr-xr-x   4 postgres  daemon   136B Jan 24 16:40 pg_log
drwx------   3 postgres  daemon   102B Jan 24 16:40 pg_notify
-rw-------   1 postgres  daemon    70B Jan 24 16:40 postmaster.opts
-rw-------   1 postgres  daemon    75B Jan 24 16:40 postmaster.pid
drwx------  20 postgres  daemon   680B Jan 24 16:39 .
drwxr-xr-x  14 root      daemon   476B Jan 24 16:34 ..
drwx------   5 postgres  daemon   170B Jan 24 16:34 base
-rw-r--r--   1 postgres  wheel     19K Jan 24 16:34 postgresql.conf
-rw-------   1 postgres  daemon     4B Jan 24 16:34 PG_VERSION
drwx------   3 postgres  daemon   102B Jan 24 16:34 pg_clog
-rw-------   1 postgres  daemon   4.1K Jan 24 16:34 pg_hba.conf
-rw-------   1 postgres  daemon   1.6K Jan 24 16:34 pg_ident.conf
drwx------   4 postgres  daemon   136B Jan 24 16:34 pg_multixact
drwx------   2 postgres  daemon    68B Jan 24 16:34 pg_serial
drwx------   3 postgres  daemon   102B Jan 24 16:34 pg_subtrans
drwx------   2 postgres  daemon    68B Jan 24 16:34 pg_tblspc
drwx------   2 postgres  daemon    68B Jan 24 16:34 pg_twophase
drwx------   4 postgres  daemon   136B Jan 24 16:34 pg_xlog
4

1 回答 1

0

我要做的第一件事是尝试通过环回适配器进行连接。psql -h localhost是一个很好的起点。

除此之外,您还想找到合适的套接字文件。您可以尝试在 finder 中查找套接字文件。注意-h可以用来指定socket所在的文件目录。

于 2013-04-22T14:08:34.383 回答