The most common problem with postgresql – it uses ASCII charset by default, and if you want to create database in UTF8, you can see the error “(UTF8) is incompatible with the encoding of the template database”.
Use these few easy steps to solve it:
su - postgres
psql
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';
DROP DATABASE template1;
CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UTF8';
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';
\c template1
VACUUM FREEZE;
Now you can use template1
for creation of your database.