'Postgres template0 template1 both removed
I mistakenly dropped both postgres's template0 and template1 and now am unable to create databases. I am currently running postgres 9.5.3 on OSX 10.11. Can I get help restoring these two templates; I have already tried an uninstall/re-install using homebrew with no luck.
Solution 1:[1]
you cannot to drop database template0 - not with any legal method. What you can do? Now, your database cluster is broken, there are two possibilities:
backup your current databases with
pg_dump. Create new database cluster withinitdb. New database cluster will have correct template0, template1You can try to create template1 from any existing database - you can use clause
TEMPLATEof statementCREATE DATABASE:
postgres=# create database template1 template postgres; ERROR: database "template1" already exists postgres=# create database template0 template postgres; ERROR: database "template0" already exists
First method should be preferred, because nobody knows, what is broken in your cluster.
Solution 2:[2]
you must create the new database with sqlmanager for postgresql, template0 appears there
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | a_horse_with_no_name |
| Solution 2 | Wilson Parra |
