无法连接PostgreSQL服务器问题求助(Homebrew安装环境)
- 此前PostgreSQL服务运行正常,今早突然无法连接;已通过Homebrew卸载重装PostgreSQL@14
- pgAdmin 4连接报错截图:

- 找不到解决方案中提及的
postgresql.conf和pg_hba.conf配置文件,确认PostgreSQL安装路径为/opt/homebrew/Cellar/postgresql@14 - 尝试相关启动方案时,多数命令返回如下提示:
WARNING: The locate database (/var/db/locate.database) does not exist.
To create the database, run the following command:
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
Please be aware that the database can take some time to generate; once the database has been created, this message will no longer appear. - 修改路径尝试启动服务器时,报错:
pg_ctl: directory "/opt/homebrew/postgres_db_cluster" does not exist.
编辑1
按PostgreSQL Wiki中Homebrew相关步骤操作后,问题仍存在:
- 执行命令:
brew services restart postgresql@14,返回:==> Successfully stopped
postgresql@14(label: homebrew.mxcl.postgresql@14)
==> Successfully startedpostgresql@14(label: homebrew.mxcl.postgresql@14) - 执行
psql postgres测试连接,报错:psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
Is the server running locally and accepting connections on that socket?
编辑2
尝试相关方案的Update 3第一步,结果如下:
abhinash.kumar@ ~ % pg_ctl -D /usr/local/var/postgres status pg_ctl: directory "/usr/local/var/postgres" is not a database cluster directory.
同时找不到该方案中提到的pg_hba.conf.sample文件
编辑3
再次尝试通过Homebrew启动服务,执行brew services start postgresql@14报错:
abhinash.kumar@ ~ % brew services start postgresql@14 Bootstrap failed: 5: Input/output error Try re-running the command as root for richer errors. Error: Failure while executing; `/bin/launchctl bootstrap gui/501 /Users/abhinash.kumar/Library/LaunchAgents/homebrew.mxcl.postgresql@14.plist` exited with 5.
内容的提问来源于stack exchange,提问作者Abhinash Jha

