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

new encoding (UTF8) is incompatible

Please follow the steps below to sought the above postgresql ERROR: new encoding (UTF8) is incompatible

We need to drop or modify template1. Templates can’t be dropped, hence we need to make make an database:

ERROR: new encoding (UTF8) is incompatible

su postgres

psql

UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';

Now we can drop it:

DROP DATABASE template1;

Create database from template0, with a new default encoding:

CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';

Now modify template1 so it’s actually a template:

UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';
-=

Now switch to template1 and VACUUM FREEZE the template:

\c template1

VACUUM FREEZE;

exit

1 thought on “ERROR: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII)

Leave a Reply