1

I have installed Odoo12 on Ubuntu 18.04 using installation script Odoo Install The server started successfully and when trying to create the first database, the error below showed up.

Database creation error: encoding "UTF8" does not match locale "en_US" DETAIL: The chosen LC_CTYPE setting requires encoding "LATIN1".

then I have run the below script which has solved the problem before on odoo 10. it was run from postgres user

psql postgres -c "update pg_database set datallowconn = TRUE where datname = 'template0';"
psql template0 -c "update pg_database set datistemplate = FALSE where datname = 'template1';"
psql template0 -c "drop database template1;"
psql template0 -c "create database template1 with ENCODING = 'UTF-8' LC_CTYPE = 'en_US.utf8' LC_COLLATE = 'en_US.utf8' template = template0;"
psql template0 -c "update pg_database set datistemplate = TRUE where datname = 'template1';"
psql template1 -c "update pg_database set datallowconn = FALSE where datname = 'template0';"

As the problem persisted I installed phpPgAdmin and noticed that the Encoding is still "Latin1" ; So I droped the database and created a new one manually from the phppgAdmin interface using same name and same owner. below is a shot from the phpPgAdmin phpPgAdmin shot screen

Still the same problem unresolved and the error is shown as seen below. Odoo Encoding Error message

Noting that this is the return of calling "locale" on my server. locale status

  • I have also tried to add "db_template = template0" in /etc/odoo-server.conf and restarted the postgresql and odoo services and still the problem unsolved. – mohammad khamis Dec 18 '18 at 07:24
  • I have managed to solve my own problem by Re-installing Ubuntu and passing $ sudo locale-gen "en_US.UTF-8" $ sudo dpkg-reconfigure locales and choosing en_US.UTF-8 as my default before installing odoo (and before PostgreSQL as well) But I hope that someone can answer my question as a benefit for the community – mohammad khamis Dec 18 '18 at 08:40

1 Answers1

0

You have to configure locale before postgres installation.

export LC_CTYPE="en_US.UTF-8"
sudo dpkg-reconfigure locales

or you can reinint db

initdb --pgdata=/path/to/postgresql -E utf8
Jack Sparrow
  • 628
  • 8
  • 20