The problem of PostgreSQL installation failure on mac

Cause analysis

By default, PostgreSQL will set the relevant directory owner to postgres. If this account is missing, the execution of the chown command will fail during the installation process, resulting in installation failure.

Two, the solution

1. Completely uninstall PostgreSQL

# 打开卸载App,路径中的15是PostgreSQL的版本,根据自己的安装情况替换即可
open /Library/PostgreSQL/15/uninstall-postgresql.app/

# 删除PostgreSQL目录
sudo rm -rf /Library/PostgreSQL/

# 删除配置文件
sudo rm /etc/postgres-reg.ini

2. Initialize the PostgreSQL user

Create a user with the dscl command: postgres

# 创建用户并指定Shell
sudo dscl . -create /Users/postgres UserShell /bin/bash

# 设置用户ID(需要唯一)、显示名称
sudo dscl . -create /Users/postgres UniqueID "5001"
sudo dscl . -create /Users/postgres RealName "postgres"# 将用户设置为管理员
sudo dscl . -create /Users/postgres PrimaryGroupID 80

# 修改密码
sudo dscl . -passwd /Users/postgres yourpassword

If you are accustomed to using a graphical interface, you can add a postgres account through the menu: System Settings -> User and Group Rental -> Add Account

Just reinstall:

Guess you like

Origin blog.csdn.net/ONLYSRY/article/details/129623732