Postgresql – How to uninstall PostgreSQL (and pgAdmin3) from OSX Sierra

installationmac os xpgadminpostgresql

I've been having some difficulty getting up and running with PostgreSQL. Having uninstalled PostgreSQL with brew uninstall postgresql and uninstalled/removed Postgres.app I re-installed Postgresql.app. When initializing the .app I was still getting this error message:

Postgres.app Error Message

Per Postgresql.app's documentation, I looked at my Activity Monitor and saw nothing named postgres or postmaster:

Activity Monitor

I found this helpful answer and after sudo find / -iname createdb discovered I had a createdb file living in /Library/PostgreSQL/9.5/bin/createdb who contents
include "pgAdmin3.app" which is no longer supported. (I am presuming I installed it when I first started looking into PostgreSQL and wasn't really thinking… whoops!) I also searched for pg_hba.conf files and found I have a postgres directory in my usr dir: /usr/local/var/postgres/pg_hba.conf

Is removing the Library's folder (/Library/PostgreSQL/) adequate for a complete uninstallation of pgAdmin3, or are there other files and directories to remove? For example, should I also delete /usr/local/var/postgres/? Any advice is greatly appreciated, thank you.

NOTE:
per pgAdmin3's uninstall site, ls -al /Applications | grep pgAdmin returns nothing.

per this similar question on another SE site, sudo find / -iname .pg* reveals nothing. Also, per the answer to that question, ~/Library/Preferences/ does not contain:
org.postgresql.pgadmin.plist.lockfile
org.postgresql.pgadmin.plist
pgadmin3 Preferences

per the comments in this answer it looks like I should remove the /usr/local/var/postgres/ directory manually. And from the question, I also invoked sudo find / -name "*postgres*" and got a whole bunch of listings. Of note, I see that BlackMagic's DaVinci Resolve is using a PostgreSQL server. The install timestamp of pgAdmin3 is the same as when I installed Resolve… ? Not sure what I need to do.

This forum conversation sheds some light on Resolve's PostgreSQL server removal.

UPDATE: per comments, when I launch Activity Monitor as admin:

sudo "/Applications/Utilities/Activity Monitor.app/Contents/MacOS/Activity Monitor"

…I see these processes associated with user:postgres
Activity Monitor, active postgres processes

Should I quit these processes before deleting the contents of /Library/Postgres/... and other associated files like:
/Library/LaunchDaemons/com.edb.launchd.postgresql-9.5.plist

/Library/Application Support/Blackmagic Design/DaVinci Resolve/Prereqs/config_postgres.sh
/Library/Application Support/Blackmagic Design/DaVinci Resolve/Prereqs/install_postgres.sh
/Library/Application Support/Blackmagic Design/DaVinci Resolve/Prereqs/postgresql.zip
/Library/Application Support/Blackmagic Design/DaVinci Resolve/Prereqs/upgrade_postgres.sh

&

/private/var/db/dslocal/nodes/Default/groups/_postgres.plist
/private/var/db/dslocal/nodes/Default/users/_postgres.plist
/private/var/db/dslocal/nodes/Default/users/postgres.plist
/private/var/folders/gv/jzhl4n_j2gz6_hjvq4f2xq9h0000gn/C/com.postgresapp.Postgres2
/private/var/folders/gv/jzhl4n_j2gz6_hjvq4f2xq9h0000gn/C/com.postgresapp.Postgres2MenuHelper

&

/Users/<user_name>/Library/LaunchAgents/com.postgresapp.Postgres2LoginHelper.plist
/Users/<user_name>/Library/Logs/Homebrew/postgresql
/Users/<user_name>/Library/Preferences/com.postgresapp.Postgres2.plist
/Users/<user_name>/Library/Preferences/com.postgresapp.Postgres2MenuHelper.plist
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Aliases/postgres
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/check_postgres.rb
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/postgres-xc.rb
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/postgresql.rb
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/postgrest.rb
/usr/local/var/homebrew/locks/postgresql.brewing
/usr/local/var/postgres
/usr/local/var/postgres/postgresql.auto.conf
/usr/local/var/postgres/postgresql.conf

Maybe I can leave the Homebrew dir/files?

Note: found these with sudo find / -name "*postgres*"

Also per this github blog, should I "Restore shared memory settings" with sudo rm /etc/sysctl.conf

Best Answer

Well, turns out I had pgAdmin3 installed by DaVinci Resolve 12.5.4's installer and their uninstaller didn't get rid of all the components it installed.

I deleted this file: /Library/LaunchDaemons/com.edb.launchd.postgresql-9.5.plist and was able to reboot without the postgres processes launching - note to use Activity Monitor as admin and displaying "All Processes"
sudo "/Applications/Utilities/Activity Monitor.app/Contents/MacOS/Activity Monitor"

I then deleted the entire contents of:
/Library/PostgreSQL/...
/usr/local/var/postgres/...
/Library/Application Support/Blackmagic Design/...

and other non rbenv & homebrew "postgres" files (tho I did nuke the homebrew postgres log) I found using sudo find / -name "*postgres*"

I've seen a couple "uninstalling" posts, and this one recommended using
sudo rm /etc/sysctl.conf but I don't think it applies to OSX Sierra's install of pgAdmin3 components from the DaVinci Resolve installer.