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=>
Magick
  • 111
  • 1
  • 4

1 Answers1

-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

Ahmad Abuhasna
  • 2,602
  • 3
  • 19
  • 36
  • with or without `-` makes no difference to the psql command – Jasen May 08 '18 at 08:12
  • @Jasen your reference please, that `-` will not do any side effect, here is my references https://dba.stackexchange.com/questions/40335/postgresql-cannot-change-directory-to-root https://stackoverflow.com/questions/35782366/postgresql-cannot-change-to-root-with-u-shortcut https://serverfault.com/questions/718176/postgres-root-permission-denied – Ahmad Abuhasna May 08 '18 at 08:18
  • ok, but it makes no difference to the database permissions – Jasen May 08 '18 at 08:22
  • @Jasen your reference please – Ahmad Abuhasna May 08 '18 at 08:27
  • just try it, you will see. – Jasen May 08 '18 at 08:40