0

I've been learning postgresql recently and made a lot of mistakes with the project I started with so I decided to drop the whole database which was called postgres.

And I kept receiving this message:

[55006] error: cannot drop the currently open database

so I closed it by force using:

DROP DATABASE postgres WITH (force)

and now I can't create new data sources or log in to my postgres account and I keep receiving this error:

error: connection to server at "localhost" (::1), port 5432 failed: FATAL: database "postgres" does not exist

what can I do about it?

I couldn't find a solution I could try because I haven't found a similar problem yet please direct me to a solution

Konstantin Annikov
  • 11,655
  • 4
  • 27
  • 40
  • You can create the database again from the command line: https://stackoverflow.com/questions/30641512/create-database-from-command-line – user3738870 Nov 17 '22 at 21:07
  • 1
    I would recommend reinstalling all over, way easier. – Jorge Campos Nov 17 '22 at 21:08
  • Connect to the `template1` database and recreate the `postgres` database. See [Template databases](https://www.postgresql.org/docs/current/manage-ag-templatedbs.html) for more information. **FYI, you should not be using the `postgres` database as your project database**. It's primary purpose is to be a database you can connect to as a starting point for doing operations on other databases. – Adrian Klaver Nov 17 '22 at 22:59

0 Answers0