Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm working in a centralized monitoring system on Windows 2008 R2, I have installed a PostgreSQL 9.3 to use psql from the command line.

When I try to access to some remote Postgres (an 8.4 in my principal case) I have an error with the encoding:

command:

psql.exe -h 192.168.114.12 -p 5432 -d db_seros_transaccion -U postgres -f script.sql

error:

psql: FATAL:  la conversión entre WIN1252 y LATIN1 no está soportada

I try adding the sentence

SET client_encoding = 'UTF8';

in my script but the problem persist (and with other encodings too, like LATIN1 & WIN1252).

After googling it I found people that update some rows in the server to make the connection, and this is a problem to me.

Can anyone help me to make a connection using psql without an update? Is it possible?

Thanks a lot and excuse my English.

share|improve this question
    
Have you tried the suggested solution in this thread, i.e. running chcp 65001 before psql? –  Milen A. Radev Jan 6 at 15:40
    
Yes, after make the question, try with chcp 65001, 437, 1252 to test. not work. now I trying to use sqlrun throw an odbc (in a minutes the results ;P) –  Frank N Stein Jan 6 at 15:51
    
The 8.4 is on Linux, right? –  Craig Ringer Jan 7 at 0:37
3  
In addition to chcp 65001 to set a unicode codepage you may also need to tell psql it's in a unicode terminal during startup. You can't SET client_encoding later, because you need an already-working connection for that. Try also running SET PGCLIENTENCODING=utf-8 (after the chcp 65001) before starting psql and report back on that. –  Craig Ringer Jan 7 at 0:40
    
Thanks a lot Craig Ringer, works, finally works! You are my new idool now! The steps are: 1. open the cmd 2. SET PGCLIENTENCODING=utf-8 3. chcp 65001 4. psql -h 192.168.114.12 -U postgres –  Frank N Stein Jan 7 at 15:13

1 Answer 1

up vote 3 down vote accepted

Thanks a lot Craig Ringer, works, finally works! You are my new idool now!

The steps are:

  1. open the cmd
  2. SET PGCLIENTENCODING=utf-8
  3. chcp 65001
  4. psql -h 192.168.114.12 -U postgres
share|improve this answer

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.