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

如何彻底卸载MacOS Catalina上通过EnterpriseDB GUI安装的PostgreSQL14

彻底卸载MacOS Catalina上EnterpriseDB版PostgreSQL 14的可行方法

我曾尝试过多个针对旧版MacOS的PostgreSQL卸载方案,但均未成功。之后尝试手动运行自带的卸载程序也遇到一系列错误:

me@myMac:~$ cd /Library/PostgreSQL/14
me@myMac:/Library/PostgreSQL/14$ ./uninstall-postgresql.app/
-bash: ./uninstall-postgresql.app/: is a directory  
me@myMac:/Library/PostgreSQL/14$ open ./uninstall-postgresql.app/
LSOpenURLsWithRole() failed with error -10810 for the file /Library/PostgreSQL/14/uninstall-postgresql.app.  
me@myMac:/Library/PostgreSQL/14$ open -a ./uninstall-postgresql.app/
Unable to find application named './uninstall-postgresql.app/'  
me@myMac:/Library/PostgreSQL/14$ open -a uninstall-postgresql.app/
Unable to find application named 'uninstall-postgresql.app/'  
me@myMac:/Library/PostgreSQL/14$ sudo open uninstall-postgresql.app/
Password:
LSOpenURLsWithRole() failed with error -10810 for the file /Library/PostgreSQL/14/uninstall-postgresql.app.  
me@myMac:/Library/PostgreSQL/14$ cd /Library/PostgreSQL/14/uninstall-postgresql.app/Contents/MacOS/
me@myMac:/Library/PostgreSQL/14/uninstall-postgresql.app/Contents/MacOS$ install
install            install_name_tool  installvst
install-info       installer  
me@myMac:/Library/PostgreSQL/14/uninstall-postgresql.app/Contents/MacOS$ installer
Usage: installer [-help] [-dominfo] [-volinfo] [-pkginfo] [-allowUntrusted] [-dumplog]
                 [-verbose | -verboseR] [-vers] [-config] [-plist]
                 [-file <pathToFile>] [-lang <ISOLanguageCode>] [-listiso]
                 [-showChoicesXML] [-applyChoiceChangesXML <pathToFile>]
                 [-showChoicesAfterApplyingChangesXML <pathtoFile>]
                 -pkg <pathToPackage>
                 -target <[DomainKey|MountPoint]>  
me@myMac:/Library/PostgreSQL/14/uninstall-postgresql.app/Contents/MacOS$ installbuilder.sh
-bash: installbuilder.sh: command not found  

手动彻底卸载步骤

1. 停止PostgreSQL服务

先确保PostgreSQL服务已停止:

sudo launchctl unload /Library/LaunchDaemons/com.edb.launchd.postgresql-14.plist

如果提示服务不存在,直接打开Activity Monitor,搜索postgres并强制退出所有相关进程。

2. 删除核心安装目录

删除PostgreSQL 14的主安装文件夹:

sudo rm -rf /Library/PostgreSQL/14

3. 清理系统配置与日志文件

  • 删除启动守护进程配置:
sudo rm /Library/LaunchDaemons/com.edb.launchd.postgresql-14.plist
sudo rm /Library/LaunchAgents/com.edb.launchd.postgresql-14.plist
  • 删除偏好设置文件:
sudo rm -rf /Library/Preferences/com.edb.postgresql.plist
  • 删除日志文件:
sudo rm -rf /Library/Logs/postgresql-14.log

4. 删除专用用户和组

EnterpriseDB安装时会创建postgres用户和组,执行以下命令删除:

sudo dscl . -delete /Users/postgres
sudo dscl . -delete /Groups/postgres

如果命令提示用户/组不存在,说明安装时未创建,可跳过此步骤。

5. 清理环境变量

检查你的shell配置文件(比如~/.bash_profile、~/.zshrc),删除任何与PostgreSQL 14相关的PATH配置行(类似export PATH="/Library/PostgreSQL/14/bin:$PATH"),然后执行:

# 如果你用bash
source ~/.bash_profile
# 如果你用zsh
source ~/.zshrc

6. 验证卸载结果

执行以下命令确认无残留:

# 检查是否还有postgres进程
ps aux | grep postgres
# 检查安装目录是否已删除
ls -la /Library/PostgreSQL/

如果没有postgres相关进程,且/Library/PostgreSQL/目录为空或已删除,说明卸载完成。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.14 20:25:29