0

I wanna restore a dumped psql file but i consistently run into this error

The command I run in terminal is:

psql -U postgres -f dumpall.sql

The error I run into is as follows:

psql:dumpall.sql:96: ERROR:  database "template1" does not exist
psql:dumpall.sql:100: ERROR:  template database "template1" does not exist
psql:dumpall.sql:101: ERROR:  option "locale" not recognized
LINE 1: ...late1 WITH TEMPLATE = template0 ENCODING = 'UTF8' LOCALE = '...
                                                             ^
psql:dumpall.sql:104: ERROR:  database "template1" does not exist
psql:dumpall.sql:106: error: \connect: FATAL:  database "template1" does not exist
  • https://stackoverflow.com/questions/66052693/copying-postgresql-local-to-remote-database-both-with-password-error-option – Joachim Isaksson Aug 22 '21 at 07:46
  • This is going to need more information: 1) What version of Postgres did you pg_dump(all) from? 2) What was the pg_dump(all) command? 3) Which version of pg_dump(all) did you use? 4) What version of Postgres are you restoring to? Add the answers as update to your question. – Adrian Klaver Aug 22 '21 at 15:48

1 Answers1

0

Somebody wrecked the PostgreSQL database cluster by dropping the template1 database.

If template0 still exists, you can create it again with

CREATE DATABASE template1 TEMPLATE template0 IS_TEMPLATE TRUE;

If not, remove the whole cluster and create it again with a new initdb.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263