Search code examples
sqldatabasepostgresqlrecovery

Dropped the default postgres database in Postgresql server


I did not know what the database did and I deleted it without realizing that now I wouldn't be able to run psql again. How do I get thngs back to normal again?


Solution

  • The postgres database isn't really needed.

    But you can re-create it using:

    psql -U postgres -d template1
    psql (13.1)
    
    postgres=# create database postgres;
    

    The -d template1 tells psql to connect to the template1 database.