8

Reading from the here, I want to uninstall postgres completely with homebrew and have used brew uninstall postgresql but I get this response.

No such keg: /usr/local/Cellar/postgresql

I know postgres is running because when I run ps auxwww | grep postgres I see /usr/local/opt/postgresql94/bin/postgres -D /usr/local/var/postgres. What am I doing wrong? I have mac Sierra

Prashant Pokhriyal
  • 3,727
  • 4
  • 28
  • 40
stackjlei
  • 9,485
  • 18
  • 65
  • 113

1 Answers1

22

I installed postgres using homebrew. I uninstalled it using the following steps:

Run the following command and look for the correct name something like postgresql94, postgres, postgresql@13. Name may varies, you have to check accordingly. In my case it was postgresql94.

brew list

After finding the correct name, run the following command to uninstall postgres. You have to replace postgresql94 with the name you found in the above mentioned command:

brew uninstall postgresql94

That should do the uninstall.


Shortcut command for the same is

brew list | grep postgres | xargs brew uninstall
Prashant Pokhriyal
  • 3,727
  • 4
  • 28
  • 40
  • THANKS! I did this and the uninstallation happened super quick so I did `ps auxwww | grep postgres` and still see the process running though. is that normal? – stackjlei Jan 25 '17 at 06:02
  • did you run it using root privileges. I think you are still able to see process because some file cannot be removed because they are currently in use. – Prashant Pokhriyal Jan 25 '17 at 06:05
  • I think I have root privileges because I'm the only one using my computer. Was I suppose to add `sudo` before the `brew uninstall postgresql`? I restarted my computer and don't see it the process anymore – stackjlei Jan 25 '17 at 06:13
  • 1
    Actually process file is still there but now it is not able to run because all the dependent files are deleted. So it's not running. – Prashant Pokhriyal Jan 25 '17 at 06:20
  • If you use homebrew why do you use sudo? Sudo works outside of Homebrew. Normally it might break things. Is it ok for removing stuff on Mac with brew with sudo? – Katarzyna Apr 13 '18 at 18:24
  • In 2021, using `sudo` causes an error. Looks like Homebrew allows us to install and uninstall as regular users now (at least for Postgres). – ankush981 Apr 23 '21 at 11:50
  • sudo brew uninstall postgresql@9.5 Password: Error: Running Homebrew as root is extremely dangerous and no longer supported. As Homebrew does not drop privileges on installation you would be giving all build scripts full access to your system. – Mel Aug 16 '21 at 00:56
  • I've updated my answer. Earlier I used `sudo` which is not required now. – Prashant Pokhriyal Aug 29 '21 at 06:24