gpt4 book ai didi

postgresql - postgres createdb 语言环境问题

转载 作者:行者123 更新时间:2023-11-29 13:11:14 25 4
gpt4 key购买 nike

由于以下原因,我在设置数据库时遇到了一些麻烦:

$ createdb -E UTF-8 -p 5432 nominatim
createdb: database creation failed: ERROR: encoding "UTF8" does not match locale "en_US"
DETAIL: The chosen LC_CTYPE setting requires encoding "LATIN1".
ERROR: Error executing external command: createdb -E UTF-8 -p 5432 nominatim

在/etc/profile 中,我将语言环境设置为 en_US.UTF-8,当我以 postgres 用户(或我自己的用户)的身份检查“语言环境”时,包括 LC_CTYPE 在内的所有变量都是“en_US.UTF-8”。此外,我还运行了 sudo locale-gen en_US en_US.UTF-8sudo dpkg-reconfigure locales。有谁知道为什么 LC_CTYPE 似乎退回到 en_US 而不是 en_US.UTF-8?

最佳答案

集群的默认语言环境由 initdb 设置:

Locale support is automatically initialized when a database cluster is created using initdb. initdb will initialize the database cluster with the locale setting of its execution environment by default [...] If you want to use a different locale (or you are not sure which locale your system is set to), you can instruct initdb exactly which locale to use by specifying the --locale option.

您可以使用 createdb --locale 覆盖新数据库的默认值.

如果您确实需要修改现有集群的默认值,您可以删除并重新创建 template1使用不同的语言环境(参见 this example )。

关于postgresql - postgres createdb 语言环境问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54441286/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com