I need to move a PostgreSql database from 8.3 Windows to 8.4 running on Linux (Ubuntu Server 12.04).
The restore aparently is ok, but when I try to show data in my program I get an error saying that some characters are not supported on WIN1252 encoding.
The original database has this properties:
Encoding: WIN1252 LC_CTYPE: English_United States.1252 LC_COLLATE: English_United States.1252
I can restore the database using LC_CTYPE = "C" and LC_COLLATE = "C", this way I get the unsupported characters in my program.
If I try to create the database using this command:
createdb -h 127.0.0.1 \
--encoding=WIN1252 \
--lc-ctype='English_United States.1252' \
--lc-collate='English_United States.1252' \
-T template0 -U postgres mydb
I get this error:
createdb: falló la creación de la base de datos:
ERROR: el nombre de configuración regional «English_United States.1252» no es válido
First of all, how can I let my O.S. include this regional configuration?.
The Windows-1252 character set is known in Ubuntu by its other name
CP1252
.Generally no corresponding locale is installed by default on Ubuntu because Unix folks prefer
iso-8859-15
orutf-8
.However the charmap should be provided by the
locales
packages. Assuming this package is installed, you may issue a command like this to create the relevant locale:Then run
sudo /etc/init.d/postgresql restart
for postgres to pick up the new locale, avoiding Postgresql 9.2 “invalid locale name” on Ubuntu 12.04.Then you should be able to run
createdb
like you did in the question except for the locale name which isen_US.CP1252
instead of the Windows-ishEnglish_United States.1252