1

I want to create a New Database that will store data in German(i.e Text with accents etc). Hence I tried to create it using the following SQL:

CREATE DATABASE testdb
  WITH ENCODING='LATIN1'
       OWNER=postgres
       TEMPLATE=template0
       CONNECTION LIMIT=-1;

When I run this on my Windows Development machine, I get the following error message:

ERROR: encoding "LATIN1" does not match locale "English_United States.1252" DETAIL: The chosen LC_CTYPE setting requires encoding "WIN1252".

On my Linux server, I get the following error message:

ERROR: encoding "LATIN1" does not match locale "en_US.UTF-8" DETAIL: The chosen LC_CTYPE setting requires encoding "UTF8".

What do I need to do to create a Database which can correctly store German text?

  • Can you specify which Linux distribution you use ? – Sahap Asci Feb 27 '18 at 11:18
  • @SahapAsci: Ubuntu 16:04 LTS, 64 Bit – Devdatta Tengshe Feb 27 '18 at 11:27
  • can you try de_DE.UTF-8 – Sahap Asci Feb 27 '18 at 11:28
1

On Linux, I was able to create a database with encoding LATIN1 by 1st initializing the database using initdb in \usr\pgsql-10\bin as initdb --encoding=en_US.iso88591. Read more about localization and available character set support.

Then restart the service using-

systemctl restart postgresql-10

This will re-initialize the template databases template0 and template1 with the new encoding and then you can create the database using

createdb <dbname>

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.