Postgresql – pg_upgrade fails with lc_ctype cluster values do not match

postgresqlpostgresql-9.1postgresql-9.2upgrade

I'm upgrading my PostgreSQL version 9.1.4 database to version 9.2.4. Both the old and the new version are the bundled versions of postgresapp.com for Mac OS X.

When trying to upgrade the database I get this error:

# pg_upgrade -b /tmp/Postgres.app/Contents/MacOS/bin \
-B /Applications/Postgres.app/Contents/MacOS/bin \
-d var-9.1 \
-D var

Performing Consistency Checks
-----------------------------
Checking current, bin, and data directories                 ok
Checking cluster versions                                   ok
Checking database user is a superuser                       ok
Checking for prepared transactions                          ok
Checking for reg* system OID user data types                ok
Checking for contrib/isn with bigint-passing mismatch       ok
Creating catalog dump                                       ok

lc_ctype cluster values do not match:  old "de_DE", new "de_DE.UTF-8"
Failure, exiting

I searched this error message and found no useful tip to fix this. Any idea?

Best Answer

You'll need to re-initdb the new database with LC_CTYPE set to de_DE (i.e. use a non-Unicode encoding); check the old DB's encoding and use the same one when you initdb the new database.

Alternately, use pg_dump and pg_restore to do a dump and reload of the old DB's contents into the new DB. This requires that you have the old DB running.