【发布时间】:2012-02-19 22:56:09
【问题描述】:
我从官方网站下载了 PostgreSQL 并运行了 .dmg 安装程序。之后我下载了 pgadmin3 并且我确实能够连接到数据库。
当我运行“psql”时,出现以下错误:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
经过几个小时的谷歌搜索,我读到了一些 $PATH 问题,所以我把它放到了我的 .bashrc 中:
export PATH=/Library/PostgreSQL/9.1/bin:$PATH
但是,这根本不能解决上述错误。经过几个小时的谷歌搜索后,我尝试运行“psql -l localhost -U postgres”。这给出了另一个错误:
psql: could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (fe80::1) and accepting
TCP/IP connections on port 5432?
经过一番谷歌搜索后,我尝试编辑 /Library/PostgreSQL/9.1/data/pg_hba.conf 并将所有出现的 'md5' 替换为 'trust'。
然后我将用户更改为 postgres 并执行 'pg_ctl stop' 和 'pg_ctl start',切换回我自己的用户并尝试再次连接,但没有运气。
这里有更多信息:
[~]$ which psql
/Library/PostgreSQL/9.1/bin/psql
ps aux | grep postgres
postgres 19022 0.0 0.0 2446096 484 ?? Ss 11:31PM 0:00.01 postgres: stats collector process
postgres 19021 0.0 0.0 2486532 1776 ?? Ss 11:31PM 0:00.01 postgres: autovacuum launcher process
postgres 19020 0.0 0.0 2486400 576 ?? Ss 11:31PM 0:00.03 postgres: wal writer process
postgres 19019 0.0 0.0 2486400 820 ?? Ss 11:31PM 0:00.05 postgres: writer process
postgres 19017 0.0 0.0 2446096 356 ?? Ss 11:31PM 0:00.01 postgres: logger process
postgres 19015 0.0 0.1 2486400 8216 s001 S 11:31PM 0:00.17 /Library/PostgreSQL/9.1/bin/postgres
sudo find / -name .s.PGSQL.5432
No file was found?!?
更新 1: 在 /etc/sysctl.conf 我添加了安装程序自述文件建议的值:
kern.sysv.shmmax=1610612736
kern.sysv.shmall=393216
kern.sysv.shmmin=1
kern.sysv.shmmni=32
kern.sysv.shmseg=8
kern.maxprocperuid=512
在进行这些设置之前,安装程序会出现错误退出,然后出现向导并安装 postgres(同样,使用 pgadmin3 可以正常工作,因此我假设数据库运行良好)。
【问题讨论】:
-
你查看过服务器日志输出吗?通常在新的 OS X 安装中,由于共享内存限制,Postgres 无法启动,请参阅willbryant.net/software/mac_os_x/…
-
刚刚检查了日志,只有很多服务器停止和启动消息,完全没有错误。我将编辑我的帖子并添加一个关于共享内存的词。我想我按照安装程序的自述文件的要求做了。
标签: osx-lion postgresql