PostgreSQL:在 Windows 上使用 psql 命令行实用程序时的编码问题 [英] PostgreSQL: encoding problems on Windows when using psql command line utility
问题描述
我在 Windows 2008 R2 上的集中监控系统中工作,我安装了 PostgreSQL 9.3 以从命令行使用 psql.
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.
当我尝试访问某些远程 Postgres(在我的主要情况下为 8.4)时,我遇到了编码错误:
When I try to access to some remote Postgres (an 8.4 in my principal case) I have an error with the encoding:
命令:
psql.exe -h 192.168.114.12 -p 5432 -d db_seros_transaccion -U postgres -f script.sql
错误:
psql: FATAL: la conversión entre WIN1252 y LATIN1 no está soportada
我尝试添加句子
SET client_encoding = 'UTF8';
在我的脚本中,但问题仍然存在(以及其他编码,如 LATIN1 和 WIN1252).
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.
谁能帮我在没有更新的情况下使用 psql 建立连接?可能吗?
Can anyone help me to make a connection using psql without an update? Is it possible?
推荐答案
非常感谢 Craig Ringer,有效,终于有效!你现在是我的新偶像!
Thanks a lot Craig Ringer, works, finally works! You are my new idool now!
步骤是:
- 打开cmd
SET PGCLIENTENCODING=utf-8
chcp 65001
psql -h your.ip.addr.ess -U postgres
这篇关于PostgreSQL:在 Windows 上使用 psql 命令行实用程序时的编码问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!