Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL: encoding problems on Windows when using psql command line utility

Tags:

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?

like image 500
Frank N Stein Avatar asked Jan 06 '14 15:01

Frank N Stein


People also ask

What is the default encoding for PostgreSQL?

ScaleGrid PostgreSQL deployments use UTF-8 as the default encoding on both client and server side. The template1 database is UTF-8 encoded, and uses the en_US. UTF-8 locale. By default any databases you create will also inherit this encoding.

Does PostgreSQL support UTF 16?

Unlike Oracle, PostgreSQL doesn't support an NVARHCHAR data type and doesn't offer support for UTF-16.


1 Answers

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 your.ip.addr.ess -U postgres
like image 128
Frank N Stein Avatar answered Oct 23 '22 08:10

Frank N Stein