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.
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 with initdb. New database cluster will have correct template0, template1
You can try to create template1 from any existing database - you can use clause TEMPLATE of statement CREATE 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With