0

Im trying to drop some databases on a postgres 9.6 server, but when I try Im told I am unable to.

I was under the impression that the postgres user was like a superuser.

su postgres
bash-4.2$ psql
could not change directory to "/root": Permission denied
psql (9.6.8)
Type "help" for help.

postgres=> DROP DATABASE d;
ERROR:  must be owner of database d
postgres=>
  • As a superuser you can always take ownership of that database, then drop it. – a_horse_with_no_name May 7 '18 at 8:13
  • hmm, superusers usally get a =# prompt, not =>. – Jasen May 7 '18 at 9:29
  • You have a previously abandoned question in postgres user is not superuser which seems closely related. – Daniel Vérité May 7 '18 at 10:58
  • Yes youre right. And I think this, and the other problem are probably due to being hacked – Magick May 8 '18 at 0:28
-1

The problem with su postgres command, you changed the user to posgress but bash (to be more specific environment) owner still root or the original user, in-order to fix this issue use su - postgres instead of su postgres

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.