Unable to drop database in Postgres

3.2k views Asked by At

I'm new to databases in general and Postgres in particular. I'm doing something wrong as I'm unable to drop a database.

Command line capture

I've searched for similar issues, but it's always someone that has lost or does not know an id/password. In this case the owner & superuser is postgres but I still can't drop my test databases.

test is an empty database, test_creation is has one table.

2

There are 2 answers

0
Abdul Baig On BEST ANSWER

You need to connect to psql using following:

PGPASSWORD=your_password_here psql -h localhost -U your_usename;

And then try to delete database. For UI you can use any software like pgAdmin III that will be much easier for you because you are new to Postgres

5
Laurenz Albe On

Only a superuser or the owner of a database can drop it.

Your prompt shows that you are not connected as superuser, and you are obviously not the database owner.

To drop a database, you must also make sure that nobody is connected to it.