Evo*_*lve 134 postgresql homebrew osx-snow-leopard
像其他一些人一样,当我在我的项目中运行rake db:migrate或者甚至为我的Ruby on Rails 3.2应用程序尝试大多数数据库任务时,我收到此错误.
PGError(无法连接到服务器:没有这样的文件或目录.服务器是否在本地运行并接受Unix域套接字上的连接"/tmp/.s.PGSQL.5432"?
很久以前我用Homebrew安装了PostgreSQL,并且在最近尝试安装MongoDB后,我的PostgreSQL安装从未如此.我正在运行OS X v10.6 Snow Leopard.
出了什么问题,我怎么能更好地理解PostgreSQL是如何设置在我的Mac上的呢?
到目前为止(我认为)这告诉我PostgreSQL没有运行(?).
ps -aef|grep postgres (ruby-1.9.2-p320@jct-ana) (develop) ?
501 17604 11329 0 0:00.00 ttys001 0:00.00 grep postgres
Run Code Online (Sandbox Code Playgroud)
但这是否告诉我PostgreSQL正在运行?
? launchctl load -w /usr/local/Cellar/postgresql/9.1.4/homebrew.mxcl.postgresql.plist (ruby-1.9.2-p136)
homebrew.mxcl.postgresql: Already loaded
Run Code Online (Sandbox Code Playgroud)
我该如何解决?我没看到什么?
PS:~/Library/LaunchAgents包含两个PostgreSQL .plist文件.我不确定这是否相关.
org.postgresql.postgres.plist
homebrew.mxcl.postgresql.plist
Run Code Online (Sandbox Code Playgroud)
我尝试了下面的结果,得到了如下结果.
$ psql -p 5432 -h localhost
psql: 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" (::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)
我已经阅读了,因为OS X安装了自己版本的PostgreSQL,而Homebrew在不同的地方安装了不同的版本,PostgreSQL命令在/ tmp /目录中查找.您需要在Stack Overflow上搜索更多内容,但基本上您可以通过符号链接PostgreSQL,以便任何查看该tmp路径的内容实际上都能找到真正的路径,如果这有意义的话.
这是我发现更多东西要尝试的链接,特别是如上所述的符号链接,Mac OSX Lion Postgres不接受/tmp/.s.PGSQL.5432上的连接.我仍然希望有人能够对OS X上安装PostgreSQL背后的概念进行合理的解释,以及为什么这么困难.
帮助进行故障排除的最新见解:
$ which psql // This tells you which PostgreSQL you are using when you run $ psql.
Run Code Online (Sandbox Code Playgroud)
然后运行:
$ echo $PATH
Run Code Online (Sandbox Code Playgroud)
要考虑的关键是:
确保要运行的PostgreSQL副本的路径条目在OS X系统的PostgreSQL路径之前进行.
这是决定运行PostgreSQL的核心要求,也是我所说的导致大多数这些问题的原因.
小智 99
检查你的postgres目录中可能没有postmaster.pid /usr/local/var/postgres/
删除它并启动服务器.
检查 - https://github.com/mperham/lunchy是launchctl的一个很好的包装器.
jos*_*iti 57
更新:如果你在OSX上,这里有一个更好的修复......
旧答案:
这是修复,更多信息在这里:
https://github.com/mxcl/homebrew/issues/5004
首先,停止db,然后
小智 49
对我来说,这是有效的
rm /usr/local/var/postgres/postmaster.pid
Run Code Online (Sandbox Code Playgroud)
sol*_*anv 14
对于你提到的上述错误,这对我有用..
1)可能会更改postgres.conf文件中未指定的默认端口,如果您在安装时提到了其他默认端口号5432.
(要么)
2)更改postgresql.conf文件中的端口号,然后重新启动数据库服务器
(要么)
3)代替psql类型的完整命令
"psql -p 5432 -h localhost"
小智 11
如果您正在运行Homebrew,请卸载Postgresql end pg gems:*
$ gem uninstall pg
$ brew uninstall postgresql
Run Code Online (Sandbox Code Playgroud)
下载并运行以下脚本以修复/ usr/local的权限:* https://gist.github.com/rpavlik/768518
$ ruby fix_homebrew.rb
Run Code Online (Sandbox Code Playgroud)
然后再次安装Postgres和pg gem:*
$ brew install postgresql
$ initdb /usr/local/var/postgres -E utf8
Run Code Online (Sandbox Code Playgroud)
要在登录运行时启动postgresql:
$ ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
Run Code Online (Sandbox Code Playgroud)
或者手动启动.
安装pg gem
$ gem install pg
Run Code Online (Sandbox Code Playgroud)
我希望有所帮助
Nel*_*elu 10
我通过升级 postgres 解决了这个问题。
brew update
brew upgrade
Run Code Online (Sandbox Code Playgroud)
然后我还必须升级数据库以与新的主要版本兼容,因为我从 10 升级到 11。
brew postgresql-upgrade-database
Run Code Online (Sandbox Code Playgroud)
(来源https://github.com/facebook/react-native/issues/18760#issuecomment-410533581)
当我将Postgres升级到9.3.x时,我遇到了这个问题.对我来说,快速修复是降级到之前的9.2.x版本(无需安装新版本).
$ ls /usr/local/Cellar/postgresql/
9.2.4
9.3.2
$ brew switch postgresql 9.2.4
$ launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
<open a new Terminal tab or window to reload>
$ psql
Run Code Online (Sandbox Code Playgroud)
这个答案提供了更全面的解释以及解决问题的其他方法.
我在使用自制软件在 Mac 10.15.5 上运行时遇到了这个错误,并且似乎是一个更新的解决方案,可以在上面没有的地方工作。
有一个名为 postmaster.pid 的文件,它应该在 postresql 退出时自动删除。
如果它不执行以下操作
所以对于这里的很多问题,似乎人们已经在运行psql并且不得不删除postmaster.pid.但是,我没有那个问题,因为我从来没有在我的系统中正确安装postgres.
这是一个在MAC OSX Yosemite中适用于我的解决方案
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin希望这可以帮助!Toodles!
此外,这个答案对我帮助最大:https://stackoverflow.com/a/21503349/3173748
| 归档时间: |
|
| 查看次数: |
209660 次 |
| 最近记录: |