• notice
  • Congratulations on the launch of the Sought Tech site

Solve the problem of PostgreSQL installation failure under macOS

1. Phenomenon and reasons

1. Problem phenomenon

Problem running post-install step. Installation may not complete correctly The database cluster initialisation failed.
image.png

2. Reason 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

# Open and uninstall the App, 15 in the path is the version of PostgreSQL, just replace it according to your own installation
open /Library/PostgreSQL/15/uninstall-postgresql.app/

# Delete the PostgreSQL directory
sudo rm -rf /Library/PostgreSQL/

# delete configuration file
sudo rm /etc/postgres-reg.ini

2. Initialize the PostgreSQL user

Create a user with the dscl command: postgres

# Create a user and specify a shell
sudo dscl . -create /Users/postgres UserShell /bin/bash

# Set user ID (need to be unique), display name
sudo dscl . -create /Users/postgres UniqueID "5001"
sudo dscl . -create /Users/postgres RealName "postgres"

# set user as admin
sudo dscl . -create /Users/postgres PrimaryGroupID 80

# change Password
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
image.png

3. Reinstall

image.png


Tags

Technical otaku

Sought technology together

Related Topic

0 Comments

Leave a Reply

+