postgresql: new encoding (UTF8) is incompatible with the encoding of the template database

postgresql_logoProblema

ERROR: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII)
HINT: Use the same encoding as in the template database, or use template0 as template.

 

Solução

Primeiro, tem que remover o banco template1. Mas, para que isso seja possível, é necessário fazer uma alteração na flag datistemplate do banco template1 para o valor FALSE.

UPDATE pg_database SET datistemplate = FALSE WHERE datname = ‘template1’;

Agora podemos remover o template1:

DROP DATABASE template1;

Banco removido, agora recriá-lo com base no banco template0 com a nova codificação, no caso UTF8:

CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = ‘UTF8’;

Modificar a flag datistemplate, agora com valor TRUE, do banco template1 para indicar que essa base de dados destina-se como um template:

UPDATE pg_database SET datistemplate = TRUE WHERE datname = ‘template1’;

Mudar para o banco template1 e executar o comandp VACUUM FREEZE:

\c template1

VACUUM FREEZE;

Problema resolvido!

Leave a Reply

Your email address will not be published. Required fields are marked *