How to Erase PostgreSQL Database Using psql

postgresqlpsql

I have psql installed in my Ubuntu system. There is a database named tmpdb in it. I want to delete it but get an error message:

must be owner of database tmpdb".

I open psql with

  $psql postgres
  psql (9.5.6)
  Type "help" for help.

  postgres=>DROP DATABASE tmpdb;
  ERROR:  must be owner of database tmpdb
  postgres=>

How can I see owner, change it, so I can delete the database?

Best Answer

You don't have to do any of that if you want to delete it the simple way is to use dropdb as a database super-user. Assuming that postgres is still a database super-user.

sudo -u postgres dropdb tmpdb;

See man dropdb for more information.