You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MacOS通过brew安装postgresql@11后服务启动失败如何解决?

  • 优先确认二进制兼容性(M1架构问题)
    postinstall报错的核心原因是initdb调用postgres -V无返回,首先直接执行以下命令验证二进制是否正常运行:
    ~/.homebrew/Cellar/postgresql@11/11.13/bin/postgres -V
    
    如果该命令无输出、报错或返回异常,就是PostgreSQL 11的安装包与M1原生架构不兼容。解决方案是打开终端的「显示简介」面板,勾选「使用Rosetta打开」,重启终端后完全卸载重装postgresql@11即可解决。
  • 手动初始化数据库集群
    postinstall执行失败会导致数据目录~/.homebrew/var/postgresql@11为空,服务自然无法启动。确认postgres -V能正常返回版本号后,手动执行初始化命令:
    ~/.homebrew/Cellar/postgresql@11/11.13/bin/initdb --locale=C -E UTF-8 ~/.homebrew/var/postgresql@11
    
    执行成功后数据目录会自动生成所需的配置、系统表文件。
  • 修复服务配置的路径解析问题
    你提供的plist配置中用了作为路径前缀,launchd加载服务时不会自动解析对应用户目录,会导致启动失败。操作步骤:
    1. 先停止现有服务:brew services stop postgresql@11
    2. 编辑plist文件~/Library/LaunchAgents/homebrew.mxcl.postgresql@11.plist,将所有~替换为你的用户目录绝对路径(比如/Users/你的用户名)
    3. 重新加载配置:launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql@11.plist
    4. 重启服务:brew services start postgresql@11
  • 关于postmaster软链接的说明
    该软链接是PostgreSQL的历史兼容设计,旧版本主进程名为postmaster,现在统一使用postgres作为主进程名,软链接是为了兼容旧脚本调用,属于正常文件,无需处理。

内容的提问来源于stack exchange,提问作者Caner Taşan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.06 21:09:04