Installation Experiences/Aug 2011: Debian Squeeze: Unable to create database (FIXED)

I was recently installing DAViCal on a virtual private server running Debian Squeeze. Following the offical Installation page I wanted to create the database running


 * 1) su postgres -c /usr/share/davical/dba/create-database.sh

This, however, didn't work:

createdb: database creation failed: ERROR: encoding UTF8 does not match locale en_US DETAIL: The chosen LC_CTYPE setting requires encoding LATIN1. Unable to create database
 * 1) su postgres -c /usr/share/davical/dba/create-database.sh

Note that there is another article on a similar issue. Unfortunately, this solution did not work for me.

Finally, I was able to track down the error: Postgre's `main' cluster was using LATIN1 as encoding, and this lead to above error. Dropping the cluster and recreating it with the appropriate locales then worked:


 * 1) pg_dropcluster --stop 8.4 main
 * 2) pg_createcluster --start --locale=en_US.UTF-8 8.4 main

Note: Make sure that you use the enter the correct PostgreSQL version in above commands!

That's it. I was able to create the database afterwards.