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=>
asked May 7, 2018 at 7:36
4
  • As a superuser you can always take ownership of that database, then drop it. Commented May 7, 2018 at 8:13
  • hmm, superusers usally get a =# prompt, not =>. Commented May 7, 2018 at 9:29
  • You have a previously abandoned question in postgres user is not superuser which seems closely related. Commented May 7, 2018 at 10:58
  • Yes youre right. And I think this, and the other problem are probably due to being hacked Commented May 8, 2018 at 0:28

1 Answer 1

-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

answered May 7, 2018 at 10:55
5
  • with or without - makes no difference to the psql command Commented May 8, 2018 at 8:12
  • @Jasen your reference please, that - will not do any side effect, here is my references dba.stackexchange.com/questions/40335/… stackoverflow.com/questions/35782366/… serverfault.com/questions/718176/… Commented May 8, 2018 at 8:18
  • ok, but it makes no difference to the database permissions Commented May 8, 2018 at 8:22
  • @Jasen your reference please Commented May 8, 2018 at 8:27
  • just try it, you will see. Commented May 8, 2018 at 8:40

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.