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

MacOS使用Homebrew启动postgresql@10服务报错问题排查

解决方案
  • 第一步:查看PostgreSQL 10的运行日志定位具体报错,执行命令:
    cat /opt/homebrew/var/log/postgresql@10.log
    如果是Intel架构的Mac,日志路径替换为/usr/local/var/log/postgresql@10.log
  • 第二步:清理历史安装遗留的冲突数据目录,执行以下命令:
    首先停止服务:
    brew services stop postgresql@10
    备份原有Homebrew版PostgreSQL 10的数据目录(避免数据丢失):
    mv /opt/homebrew/var/postgresql@10 /opt/homebrew/var/postgresql@10.bak
    重新初始化数据目录:
    initdb --locale=C -E UTF-8 /opt/homebrew/var/postgresql@10
    Intel架构Mac将路径中的/opt/homebrew替换为/usr/local即可;如果本地安装了多个版本的PostgreSQL,可使用全路径执行initdb命令:/opt/homebrew/opt/postgresql@10/bin/initdb --locale=C -E UTF-8 /opt/homebrew/var/postgresql@10
  • 第三步:修正数据目录权限:
    sudo chown -R $(whoami) /opt/homebrew/var/postgresql@10
  • 第四步:重新启动服务验证状态:
    brew services start postgresql@10
    启动完成后执行以下命令检查服务状态:
    brew services list
    状态正常的情况下可执行以下命令验证连接:
    psql postgres
  • 第五步:如果仍启动失败,可直接手动运行服务进程查看实时报错:
    /opt/homebrew/opt/postgresql@10/bin/postgres -D /opt/homebrew/var/postgresql@10
    执行后终端会直接输出启动失败的具体原因,可根据报错针对性处理。

内容的提问来源于stack exchange,提问作者SGiux

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.30 20:18:03