So I'm walking through the GeoDjango tutorial and I'm stuck on this error message:
postgres@lucid32:~$ createdb -E UTF8 template_postgis
createdb: database creation failed: ERROR: encoding UTF8 does not match locale en_US
DETAIL: The chosen LC_CTYPE setting requires encoding LATIN1.
I've googled and read some Ubuntu docs but to no avail. Any insight would be greatly appreciated!
I'm using the default Vagrant Box lucid 32, for testing out my setup.
The LC_COLLATE and LC_CTYPE settings are determined when a database is created, and cannot be changed except by creating a new database. Other locale settings including LC_MESSAGES and LC_MONETARY are initially determined by the environment the server is started in, but can be changed on-the-fly.
You cannot to change these values for already created databases. In this moment, when there are not other databases, the most easy solution is a) stop database, b) delete data directory, c) run manually initdb with options --encoding and --locale (run this command under postgres user).
Often the default collation is set by initdb when the PostgreSQL cluster is first created. The collation and other locale components can be set using defaults from the operating system environment, and then inherited by databases created later.
It is better to just specify the locale for the database and have the encoding be figured out from that. So use something like
createdb --locale=en_US.utf8 template_postgis
Both -E UTF8 and --locale=en_US.utf8 are needed
$ createdb -E UTF8 -T template0 --locale=en_US.utf8 template_postgis
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With