1

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.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
Treizh
  • 322
  • 5
  • 12
  • Please [edit] your post and show the data as _text_, not as an image. Also, your user `fmavianemac` is in no group and has no permissions. So as that user you cannot do anything with the `test` database. What is your exact quesstion? Maybe you want to ask how to recover/reset the `root`/`postgres` password of a database? – Corion Jan 07 '19 at 12:02
  • https://stackoverflow.com/questions/10845998/i-forgot-the-password-i-entered-during-postgres-installation – Corion Jan 07 '19 at 12:03

2 Answers2

1

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

Abdul Baig
  • 3,683
  • 3
  • 21
  • 48
0

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.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
  • I don't understand. I'm connected as postgress which is labeled as superuser in the roles. – Treizh Jan 07 '19 at 12:25
  • Now I get it '>' for user '#' for root – Treizh Jan 07 '19 at 12:29
  • 2
    @Treizh: `psql postgres` connects you to the database named postgres, not as the user postgres. To connect as the superuser you need to use `psql -U postgres ...` –  Jan 07 '19 at 12:46
  • @a_horse_with_no_name: Thanks, so if a type psql postgres as which user im I connected? – Treizh Jan 07 '19 at 13:04
  • 1
    If you don't specify a database user, the default will be taken from the `PGUSER` environment variable, and if that is not set, the name of the operating system user is used – Laurenz Albe Jan 07 '19 at 13:22