【发布时间】:2013-01-09 15:14:43
【问题描述】:
我们的 postgres 生产数据库服务器有一个名为 crd_production 的数据库,它源自 template1 模板数据库。顺便说一句,在 Ubuntu 12.04 机器上,初始创建 pgcluster 时 template1 和 template0 数据库的默认编码具有 LATIN1 的默认编码。我已经删除了template1 db,并使用 utf-8 编码重新创建了它,如下所示。
Name | Owner | Encoding | Collate | Ctype | Access privileges
----------------+----------+----------+------------+------------+-----------------------
crd_production | deployer | UTF8 | en_US.utf8 | en_US.utf8 |
postgres | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
template0 | postgres | LATIN1 | en_US | en_US | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
(4 rows)
我们最终部署了我们的 rails(3.2.11) 应用程序并开始使用 crd_production 数据库作为主数据库。 ActiveRecord 正在写入/读取数据时没有问题,但是当我尝试从该数据库上的psql 命令行触发任何 sql 查询时,会出现以下错误 -
crd_production=# select * from users;
ERROR: character with byte sequence 0xe2 0x80 0x9c in encoding "UTF8" has no equivalent in encoding "LATIN1"
crd_production=# select * from features;
ERROR: character with byte sequence 0xe2 0x80 0x99 in encoding "UTF8" has no equivalent in encoding "LATIN1"
这可能是什么问题?是客户端的问题吗?
【问题讨论】:
标签: postgresql encoding latin1