mbr*_*chh 3 postgresql osx-lion
我从官方网站下载了PostgreSQL并运行了.dmg安装程序.之后我下载了pgadmin3,我确实能够连接到数据库.
当我运行'psql'时,我收到以下错误:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
Run Code Online (Sandbox Code Playgroud)
经过几个小时的谷歌搜索,我读到了一些$ PATH问题,所以我把它放到我的.bashrc中:
export PATH=/Library/PostgreSQL/9.1/bin:$PATH
Run Code Online (Sandbox Code Playgroud)
但是,这根本不能解决上述错误.经过几个小时的谷歌搜索,我试图运行'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?
Run Code Online (Sandbox Code Playgroud)
在进行了一些谷歌搜索之后,我尝试编辑/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?!?
Run Code Online (Sandbox Code Playgroud)
更新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
Run Code Online (Sandbox Code Playgroud)
在这些设置之前,安装程序退出时出现错误,然后出现向导并安装postgres(再次使用pgadmin3工作,所以我假设数据库运行正常).
lsof在主进程上运行所有这些.在你的情况下它是19015年(显示我的PID):
> sudo lsof -p 286 | awk '$5 == "unix" && $NF ~ /\// { print $NF }'
/tmp/.s.PGSQL.5432
Run Code Online (Sandbox Code Playgroud)
你可以放弃awk,但基本上它正在获取postgres正在监听的UNIX套接字.从那里,您可以使用-h选项psql(但仅包括目录).
> psql -h /tmp template1
template1=# \q
Run Code Online (Sandbox Code Playgroud)
如果这不起作用,您可以检查lsof输出以显示它实际正在侦听的TCP端口,如果它不是5432,请使用-ppostgres选项
| 归档时间: |
|
| 查看次数: |
8048 次 |
| 最近记录: |