Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have a dmp file I have created using pg_dump encoded in WIN1252. What I would like to do is import it using pg_restore to a database on a Linux machine. The problem is that on the windows machine postgreSQL recognizes the encoding WIN1252 but not the CP1252 encoding (they both are identical just different names for the same standard). On the Linux machine, postgreSQL recognizes CP1252 but not WIN1252. So when I try and do a pg_restore I get an error because WIN1252 is not recognized as a proper encoding. Also, if I try to do a pg_dump on windows and specify the encoding as CP1252, I get a similar error. I would like to stick with this encoding format so doing a pg_dump in utf8 or something is not something I would like to do. Any help would be appreciated!

EDIT: Actually, upon further investigation, postgreSQL does not understand cp1252. The iconv linux command used to convert a text file from one encoding to another understands cp1252 and not win1252 and thats where I got it from. On the Linux machine, I still cannot set the client encoding to WIN1252. This is the error message:

FATAL:  conversion between WIN1252 and LATIN1 is not supported

The variable client_encoding was originally set to UTF8 on the Linux machines so I dont know where LATIN1 is coming from. Unless WIN1252 is not supported so postgres tries to convert it to latin1 because that is the closest thing to it and fails at achieving that due to some character miss-match?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

I suppose the dump file you have is encoded in WIN1252 and the target database on Linux has LATIN1 as the server encoding. That's not going to work, as the error message says.

I suggest you reinitialize the target database using UTF8.

Alternatively, create the dump in UTF8 using the pg_dump -E option.

share|improve this answer
add comment

The solution is to use the "iconv" utility. cat dump.sql | iconv | psql. This usually cleans up your encoding.

See: http://www.documentroot.com/2013/12/utf8-encoding-and-postgres-dump.html

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.