[英]PostgreSQL: encoding problems on Windows when using psql command line utility
我在 Windows 2008 R2 上的集中监控系统中工作,我已经安装了 PostgreSQL 9.3 以从命令行使用psql 。
当我尝试访问一些远程 Postgres(在我的主要情况下为 8.4)时,我的编码出现错误:
命令:
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)。
谷歌搜索后,我发现有人更新服务器中的某些行以建立连接,这对我来说是个问题。
任何人都可以帮助我在没有更新的情况下使用psql建立连接吗? 可能吗?
非常感谢Craig Ringer ,有效,终于有效! 你现在是我的新偶像了!
步骤是:
SET PGCLIENTENCODING=utf-8
chcp 65001
psql -h your.ip.addr.ess -U postgres
Windows 10 / Windows 服务器 2016 或更高版本:
Windows Control Panel
Region (and Language)
Change system locale
Beta: Use Unicode UTF-8 for worldwide language support
或者
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage]
"ACP"="65001"
"OEMCP"="65001"
"MACCP"="65001"
PowerShell 控制台和 CMD 将正确显示西里尔字母
作为一个选项,尝试在 psql 中输入以下命令:
postgres=# \! chcp 65001
65001 等于 UTF-8
1251 = 赢得 1251
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.