1

I am having a spot of trouble setting up a db due to the following :

$ createdb -E UTF-8 -p 5432 nominatim
createdb: database creation failed: ERROR:  encoding "UTF8" does not match locale "en_US"
DETAIL:  The chosen LC_CTYPE setting requires encoding "LATIN1".
ERROR: Error executing external command: createdb -E UTF-8 -p 5432 nominatim

In /etc/profile I set locale to en_US.UTF-8 and when I check 'locale' as postgres user (or my own user) all vars including LC_CTYPE are 'en_US.UTF-8'. Also, I have run sudo locale-gen en_US en_US.UTF-8 and sudo dpkg-reconfigure locales. Does anyone have a clue why LC_CTYPE seems to be falling back to en_US and not en_US.UTF-8?

jeremy_rutman
  • 3,552
  • 4
  • 28
  • 47

1 Answers1

1

The default locale for a cluster is set by initdb:

Locale support is automatically initialized when a database cluster is created using initdb. initdb will initialize the database cluster with the locale setting of its execution environment by default [...] If you want to use a different locale (or you are not sure which locale your system is set to), you can instruct initdb exactly which locale to use by specifying the --locale option.

You can override the default for a new database with createdb --locale.

If you really need to modify the default for an existing cluster, you can drop and recreate template1 with a different locale (see this example).

Nick Barnes
  • 19,816
  • 3
  • 51
  • 63
  • this did the trick. see also https://stackoverflow.com/questions/13115692/encoding-utf8-does-not-match-locale-en-us-the-chosen-lc-ctype-setting-requires for explicit instructions for how to create the new db with utf-8 support – jeremy_rutman Jan 30 '19 at 14:57