在我做了brew更新和brew升级之后,我的postgres遇到了一些问题.我试图卸载postgres并重新安装,但它也没有用.
这是错误消息.(当我尝试执行rake db:migrate时,我也收到此错误消息)
$ 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"?
Run Code Online (Sandbox Code Playgroud)
我该如何解决?
Mac版:山狮.
自制版:0.9.3
postgres版本:psql(PostgreSQL)9.2.1
这就是我所做的.
12:30 ~/D/works$ brew uninstall postgresql
Uninstalling /usr/local/Cellar/postgresql/9.2.1...
12:31 ~/D/works$ brew uninstall postgresql
Uninstalling /usr/local/Cellar/postgresql/9.1.4...
12:31 ~/D/works$ psql --version
bash: /usr/local/bin/psql: No such file or directory
12:33 ~/D/works$ brew install postgresql
==> Downloading http://ftp.postgresql.org/pub/source/v9.2.1/postgresql-9.2.1.tar.bz2
Already downloaded: /Library/Caches/Homebrew/postgresql-9.2.1.tar.bz2
......
......
==> Summary
/usr/local/Cellar/postgresql/9.2.1: 2814 files, 38M, built in …Run Code Online (Sandbox Code Playgroud) 我刚刚用homebrew安装了posgresql,当我继续输入命令时
psql
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.6.2.dylib
Referenced from: /usr/local/bin/psql
Reason: image not found
[1] 69711 trace trap psql
Run Code Online (Sandbox Code Playgroud)
有没有人知道什么是错的?
像其他一些人一样,当我在我的项目中运行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 …Run Code Online (Sandbox Code Playgroud) 我设法让我的本地开发环境变得笨拙.
我所有的本地Rails应用程序现在都给出错误:
PGError
could not connect to server: Permission denied
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
Run Code Online (Sandbox Code Playgroud)
我不知道是什么造成的.
在搜索解决方案时,我更新了所有捆绑的宝石,更新的系统宝石,更新的MacPorts.没有快乐.
其他人在从OSX Leopard升级到Lion时报告了这个问题,因为混淆应该使用哪个版本的Postgres(即OSX版本或MacPorts版本).我已经在Lion运行了几个月,所以现在这应该发生似乎很奇怪.
如果不先了解问题是什么,我就不愿意过多地捣乱.如何有条不紊地调试?
如何确定我的系统中有多少版本的PostgreSQL,正在访问哪一个版本以及它所在的位置?如果使用错误的PostgreSQL,我该如何解决这个问题?
抱歉没有问题.我还在学习它是如何工作的!谢谢你的任何指示.
编辑
一些更新基于以下建议和评论.
我试图运行pg_lsclusters哪个返回command not found错误.
然后我尝试本地化我的pg_hba.conf文件并找到这三个示例文件:
/opt/local/share/postgresql84/pg_hba.conf.sample
/opt/local/var/macports/software/postgresql84/8.4.7_0/opt/local/share/postgresql84/pg_hba.conf.sample
/usr/share/postgresql/pg_hba.conf.sample
Run Code Online (Sandbox Code Playgroud)
所以我假设安装了3个版本的PSQL?Macports,OSX默认和???.
然后我搜索了ps -ef | grep postgres返回的launchctl启动脚本
0 56 1 0 11:41AM ?? 0:00.02 /opt/local/bin/daemondo --label=postgresql84-server --start-cmd /opt/local/etc/LaunchDaemons/org.macports.postgresql84-server/postgresql84-server.wrapper start ; --stop-cmd /opt/local/etc/LaunchDaemons/org.macports.postgresql84-server/postgresql84-server.wrapper stop ; --restart-cmd /opt/local/etc/LaunchDaemons/org.macports.postgresql84-server/postgresql84-server.wrapper restart ; --pid=none
500 372 1 0 11:42AM ?? 0:00.17 …Run Code Online (Sandbox Code Playgroud) 我刚刚使用OS X Server将我的MacMini服务器从Lion Server升级到Mountain Lion.我在去年第一次安装Lion Server时遇到了与PostgreSQL相同的问题.
当我尝试做任何类型的PostgreSQL终端命令时,我得到了许多多年来得到的以下臭名昭着的错误消息:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
Run Code Online (Sandbox Code Playgroud)
当我收到错误时,我试图更改_postgres的密码.我尝试了几个命令,但得到了同样的错误.我只是重新启动了我的服务器,但没有运气.我以root身份登录以查看/ var/pgsql_socket,该文件夹为空.文件夹/ var/pgsql_socket_alt也是空的.
我在网上查了一下这个.然而,我所阅读的所有解决方案,包括Stack Overflow,都建议删除并重新安装PostgreSQL.我不知道,但这似乎不是一个合理的选择,因为Server App上的几个选项使用PostgreSQL.我联系了Apple Enterprise Support(没有协议),我被告知我的问题必须由开发人员解决,这将投入695美元.
我现在有一个网站,因为我无法重建它.此时我不知道在哪里寻求帮助.我会继续在线查看我是否能找到一些东西.但是我希望有人可以快速给我一个答案,这样我就可以重建我的数据库了.
更新:12/13/2012 15:33 GMT-6
这是ps auwwx | grep postg的输出:
_postgres 28123 0.0 0.1 2479696 7724 ?? Ss 3:01PM 0:00.04 /Applications/Server.app/Contents/ServerRoot/usr/bin/postgres_real -D /Library/Server/PostgreSQL For Server Services/Data -c listen_addresses= -c log_connections=on -c log_directory=/Library/Logs/PostgreSQL -c log_filename=PostgreSQL_Server_Services.log -c log_line_prefix=%t -c log_lock_waits=on -c log_statement=ddl -c logging_collector=on …Run Code Online (Sandbox Code Playgroud) 我正试图psql在我的Vagrant机器上运行,但是我收到了这个错误:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting connections on
Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Run Code Online (Sandbox Code Playgroud)
注意:Vagrant 1.9.2 Box:ubuntu/trusty64,https://atlas.hashicorp.com/ubuntu/boxes/trusty64
编辑 命令我用来安装和运行postgres:
sudo apt-get updatesudo apt-get install postgresqlsudo su postgrespsql -d postgres -U postgres每次运行我的Rails应用程序时都会收到此错误(它无法连接到我的本地Postgresql)
/Users/leonardo/.rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.11/lib/
active_record/connection_adapters/postgresql_adapter.rb:1208:in `initialize':
could not connect to server: No such file or directory (PG::Error)
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
Run Code Online (Sandbox Code Playgroud)
我正在使用Postgres.app,它正确运行.
如果我跑
$ psql
Run Code Online (Sandbox Code Playgroud)
我可以正确登录到Postgresql控制台.
$ which psql
/Applications/Postgres.app/Contents/MacOS/bin/psql
Run Code Online (Sandbox Code Playgroud)
的Gemfile
source 'https://rubygems.org'
ruby "1.9.3"
gem 'rails', '3.2.11'
gem "pg"
Run Code Online (Sandbox Code Playgroud)
database.yml的
development:
adapter: postgresql
encoding: unicode
username: leonardo
password:
database: zapping
port: 5432
Run Code Online (Sandbox Code Playgroud)
Postgresql(控制台)
$ psql
leonardo=# \l
Run Code Online (Sandbox Code Playgroud)

我最近使用Homebrew在我的Mac上安装了PostGIS(El Capitan 10.11.4,Postgres是9.5.1版),我遵循这些说明 - http://morphocode.com/how-to-install-postgis-on- MAC-OS-X /
当我尝试使用Postgres时
pg_ctl -D /usr/local/var/postgres start
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
$ FATAL: lock file "postmaster.pid" already exists
HINT: Is another postmaster (PID 280) running in data directory "/usr/local/var/postgres"?
Run Code Online (Sandbox Code Playgroud)
所以我花了几个小时研究如何解决这个问题,但无济于事.
值得注意的是,我试图按照超级用户的回答中的建议杀死PID - https://superuser.com/questions/553045/fatal-lock-file-postmaster-pid-already-exists- (在上面的例子中,我跑了kill 208),但是当我再次尝试启动Postgres时,
我得到了同样的错误,尽管有不同的PID号.我看到一些人建议删除postmaster.pid文件,但我觉得我应该保存它作为最后的手段......
不可否认,我不确定如何解决这个问题的一部分原因是我不太清楚postmaster甚至是什么 - 我只是开始了解所有这些.
通过psql db_name命令跳转到Postgres数据库工作得很好,这是值得的.
发生了什么事mimemagic?@rails activerecord 依赖于 @basecamp marcel,后者依赖于 mimemagic 0.3.2。既然 mimemagic 0.3.2 已经被猛拉,那么前进的道路是什么?
我在 Mac 上通过 Brew 安装了 Postgres。然后,我尝试启动它
| => brew services restart postgres
Stopping `postgresql`... (might take a while)
==> Successfully stopped `postgresql` (label: homebrew.mxcl.postgresql)
==> Successfully started `postgresql` (label: homebrew.mxcl.postgresql)
Run Code Online (Sandbox Code Playgroud)
之后,我检查进程是否正在运行
(base) ________________________________________________________________________________
| ~/ @ MacBook-Pro (user)
| => ps -ef | grep postgres
501 61568 561 0 5:00PM ttys000 0:00.00 grep postgres
Run Code Online (Sandbox Code Playgroud)
此外,brew services还产生以下
| => brew services
Name Status User Plist
dnsmasq unknown root /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
emacs stopped
postgresql error root /Library/LaunchDaemons/homebrew.mxcl.postgresql.plist
postgresql@12 stopped
rabbitmq stopped …Run Code Online (Sandbox Code Playgroud) 我在 Ubuntu 16.04 上安装了 postgresql,当我运行psql命令时出现此错误:
无法连接到服务器:没有这样的文件或目录。服务器是否在本地运行并接受 Unix 域套接字“/var/run/postgresql/.s.PGSQL.5432”上的连接?
我尝试重新启动并重新加载 postgres 服务,但每次都会显示错误。
我最近更新了我的机器(运行Mountain Lion的MacBook Pro),从那时起,每当我设置一个rails项目时,我的机器就会崩溃,无法连接到PG.目前,这是我尝试去localhost时遇到的错误;
PG :: ERROR无法连接到服务器:连接被拒绝服务器是否在主机"localhost"
(:: 1)上运行并接受端口5432上的TCP/IP连接?无法连接到服务器:连接被
拒绝服务器是否在主机"localhost"(127.0.0.1)上运行并接受端口5432上的TCP/IP连接?无法连接到服务器:连接被拒绝服务器是否在主机"localhost"(fe80 :: 1)上运行并接受端口5432上的TCP/IP连接?
这是一份清单,以及我尝试的事项清单;
host: localhost我的database.yml文件brew uninstall postgresql然后跑brew install postgresqlRan locate pg_hba.conf和终端出局了;
WARNING: The locate database (/var/db/locate.database) does not exist.
Run Code Online (Sandbox Code Playgroud)我也尝试过使用rails 4.0,但我仍然遇到了问题
在我更新计算机之前,我仍然可以在我的机器上处理启动/完成的其他项目.
当我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"?
我真的迷失在这里,不知道还能做什么.任何帮助将非常感激.
更新:
感谢这个问题,只需下载Postgres.app for Mac 即可解决所有问题.现在一切都很好.
我刚刚将我的mac OS X更新为Yosemite,版本10.10.4,并将postgresql更新为:psql(PostgreSQL)9.4.4.
在我的Rails 4.2.1应用程序上运行rake db:migrate后,我的终端会话响应:
rake aborted!
PG::ConnectionBad: 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?
Run Code Online (Sandbox Code Playgroud)
在我的终端会话中简单地输入psql也会显得有些偏差:
$ 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"? …Run Code Online (Sandbox Code Playgroud) postgresql ×12
macos ×5
homebrew ×3
psql ×2
database ×1
libreadline ×1
osx-server ×1
pg ×1
postgis ×1
rails-4-2-1 ×1
ruby ×1
ubuntu-16.04 ×1
vagrant ×1