p> 这里有更多信息: [〜] $其中psql /Library/PostgreSQL/9.1/bin/psql ps aux | grep postgres postgres 19022 0.0 0.0 2446096 484 ?? Ss 11:31 PM 0:00.01 postgres:统计收集器进程 postgres 19021 0.0 0.0 2486532 1776 ?? Ss 11:31 PM 0:00.01 postgres:autovacuum启动器进程 postgres 19020 0.0 0.0 2486400 576 ?? Ss 11:31 PM 0:00.03 postgres:wal writer process postgres 19019 0.0 0.0 2486400 820 ?? Ss 11:31 PM 0:00.05 postgres:编写者进程 postgres 19017 0.0 0.0 2446096 356 ?? Ss 11:31 PM 0:00.01 postgres:记录程序进程 postgres 19015 0.0 0.1 2486400 8216 s001 S 11:31 PM 0:00.17 /Library/PostgreSQL/9.1/bin/postgres sudo find / -name .s.PGSQL.5432 找不到文件?!? 更新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可以正常工作,因此我假设数据库正在运行解决方案在主进程上运行 lsof 这个。在您的情况下为19015(与我的PID一起显示): >须藤lsof -p 286 | awk’$ 5 == unix&& $ NF〜/ \ // {print $ NF}' /tmp/.s.PGSQL.5432 您可以不使用awk,但基本上它是通过Postgres监听的UNIX套接字获得的。从那里,您可以使用 -h 选项来 psql (但仅包括目录)。 > psql -h / tmp template1 template1 =#\q 如果不是工作时,您可以检查 lsof 的输出,以显示实际正在监听的TCP端口,如果不是5432,请使用 -p 选项 I downloaded PostgreSQL from the official website and ran the .dmg installer. After that I downloaded pgadmin3 and I am indeed able to connect to the database.when I run 'psql' I get the following error:psql: could not connect to server: No such file or directory Is the server running locally and acceptingAfter hours of googling I read about some $PATH issues, so I put this into my .bashrc:export PATH=/Library/PostgreSQL/9.1/bin:$PATHHowever, this doesn't solve the error above at all. After some more hours of googling I tried to run 'psql -l localhost -U postgres'. This gives another error: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?After some more googling I tried to edit /Library/PostgreSQL/9.1/data/pg_hba.conf and replaced all occurrences of 'md5' with 'trust'.Then I changed user to postgres and executed 'pg_ctl stop' and 'pg_ctl start', switched back to my own user and tried to connect again, no luck.Here are some more infos:[~]$ which psql/Library/PostgreSQL/9.1/bin/psqlps aux | grep postgrespostgres 19022 0.0 0.0 2446096 484 ?? Ss 11:31PM 0:00.01 postgres: stats collector processpostgres 19021 0.0 0.0 2486532 1776 ?? Ss 11:31PM 0:00.01 postgres: autovacuum launcher processpostgres 19020 0.0 0.0 2486400 576 ?? Ss 11:31PM 0:00.03 postgres: wal writer processpostgres 19019 0.0 0.0 2486400 820 ?? Ss 11:31PM 0:00.05 postgres: writer processpostgres 19017 0.0 0.0 2446096 356 ?? Ss 11:31PM 0:00.01 postgres: logger processpostgres 19015 0.0 0.1 2486400 8216 s001 S 11:31PM 0:00.17 /Library/PostgreSQL/9.1/bin/postgressudo find / -name .s.PGSQL.5432No file was found?!?Update 1:In /etc/sysctl.conf I added the values suggested by the installer's README:kern.sysv.shmmax=1610612736kern.sysv.shmall=393216kern.sysv.shmmin=1kern.sysv.shmmni=32kern.sysv.shmseg=8kern.maxprocperuid=512Before these settings, the installer quits with an error, afterwards the wizard appears and installs postgres (and again, using pgadmin3 works, so I assume that the database is running fine). 解决方案 Run lsof on the master process to all of this. In your case it's 19015 (shown with my PID):> sudo lsof -p 286 | awk '$5 == "unix" && $NF ~ /\// { print $NF }'/tmp/.s.PGSQL.5432You can leave off the awk, but basically it's getting the UNIX socket on which postgres is listening. From there, you can use the -h option to psql (but only include the directory).> psql -h /tmp template1template1=# \qIf that doesn't work, you can check the lsof output to show you what TCP port it's actually listening on, and if it's not 5432, use the -p option to postgres 这篇关于如何在OSX Lion上安装PostgreSQL 9.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-26 12:06