Postgresql – postgres user cannot drop database

postgresql

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=>

Best Answer

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