0

I'm am attempting to reinstall PostgreSQL as I am unable to log into it at all. I realise I had installed it a long time ago using both the installer from the postgres website and brew install postgres. I have uninstalled both of these now:

However I have a _postgres user left in /etc/passwd:

$ grep post /etc/passwd
_postgres:*:216:216:PostgreSQL Server:/var/empty:/usr/bin/false

There are no userdel or usermod commands available on Mac (10.11 El Capitan) and the alternative seems excessively complex (but perhaps necessarily so?)

1 Answer 1

2

Use the command brew remove postgresql. Or investigate the uninstall scripts manually.

Edit: Have you tried this?

  • Quit Postgres.app & drag it to the Trash

  • Delete the data directory (default location: ~/Library/Application Support/Postgres)

  • Delete preferences for Postgres.app by executing the following command: defaults delete com.postgresapp.Postgres2

  • Remove the $PATH config for the command line tools (optional): sudo rm /etc/paths.d/postgresapp

Edit 2: To delete a user from the command line, boot into single user mode. Hold Command-s at startup. Check the filesystem: /sbin/fsck -fy If no remaining errors, mount the filesystem: /sbin/mount -uw / Start up directory services: launchctl load /System/Library/LaunchDaemons/com.apple.DirectoryServices.plist Note that single user mode said to use com.apple.DirectoryServicesLocal.plist, but that didn't work -- this did. Find what groups the user belongs to: dscl . -list /groups GroupMembership | grep username -- repeat for each group except for the user's own group. Remove the group corresponding to the username: dscl . delete /groups/username (this may not be necessary -- you may get an error that the group doesn't exist; you can ignore it and go on). Remove the user account: dscl . delete /users/username At this point, you may wish to remove or archive the user folder in /Users. You may wish to remove the .AppleSetupDone file in /var/db to cause the Setup Assistant to run when next booted. Type reboot to reboot the system or shutdown -h now to shut down the system.

6
  • thanks for the help. I have edited answer to make it clear I have already run this command
    – AJP
    May 18, 2017 at 20:27
  • 1
    Oh - well, perhaps then reading the install/uninstall scripts will not be helpful.
    – user2497
    May 18, 2017 at 20:28
  • 1
    I once messed around in the guts of OSX, assuming a normal passwd/group configuration. Even then it was a filthy experience. Jobs certainly made FreeBSD weirder.
    – user2497
    May 18, 2017 at 20:34
  • 1
    It is prudent to perform a backup. I am not sure why they got rid of the classical passwd/group system, but it is certainly possible regardless of this obfuscation. When I went cavediving in OSX, I was also removing a user account that wouldn't be removed with conventional weapons, but that was long ago.
    – user2497
    May 18, 2017 at 20:44
  • 1
    IIRC, on a multivolume setup, if you have your Users folder on another disk, you must invoke mount -uwa
    – user2497
    May 18, 2017 at 20:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .