在OSX上连接到EnterpriseDB的postgres

时间:2013-01-24 22:24:43

标签: macos postgresql

我在我的机器上本地运行了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

我不是数据的所有者/,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

1 个答案:

答案 0 :(得分:0)

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

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