为 PostgreSQL 和 PostGIS 使用更改 LC_CTYPE
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8351436/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change LC_CTYPE for PostgreSQL and PostGIS use
提问by a.m.
So I'm walking through the GeoDjango tutorial and I'm stuck on this error message:
所以我在浏览 GeoDjango 教程时遇到了这个错误消息:
postgres@lucid32:~$ createdb -E UTF8 template_postgis
createdb: database creation failed: ERROR: encoding UTF8 does not match locale en_US
DETAIL: The chosen LC_CTYPE setting requires encoding LATIN1.
I've googled and read some Ubuntu docs but to no avail. Any insight would be greatly appreciated!
我用谷歌搜索并阅读了一些 Ubuntu 文档,但无济于事。任何见解将不胜感激!
I'm using the default Vagrant Box lucid 32, for testing out my setup.
我使用默认的 Vagrant Box lucid 32 来测试我的设置。
采纳答案by Peter Eisentraut
It is better to just specify the locale for the database and have the encoding be figured out from that. So use something like
最好只指定数据库的语言环境并从中找出编码。所以使用类似的东西
createdb --locale=en_US.utf8 template_postgis
回答by aarti
Both -E UTF8 and --locale=en_US.utf8 are needed
需要 -E UTF8 和 --locale=en_US.utf8
$ createdb -E UTF8 -T template0 --locale=en_US.utf8 template_postgis
回答by Freelancer
Else, try this when you log in to postgresql :
否则,请在登录 postgresql 时尝试此操作:
create database databse_name with owner database_owner encoding='UTF-8'lc_collate='en_US.utf8' lc_ctype='en_US.utf8' template template0;
回答by user535010
look at this: https://askubuntu.com/questions/20880/unicode-in-postgresql-8-4/114922#114922
看看这个:https: //askubuntu.com/questions/20880/unicode-in-postgresql-8-4/114922#114922
maybe you need configure the locale before to create the cluster
也许您需要在创建集群之前配置语言环境
~#export LANGUAGE=en_US.UTF-8
~#export LANG=en_US.UTF-8
~#export LC_ALL=en_US.UTF-8
~#locale-gen en_US.UTF-8
~#dpkg-reconfigure locales
回答by Some Guy
You need to set your operating system's locale to any utf8 compatible locale. Run locale -a
to get a list of locales you can use, and then do something like update-locale LANG=en_US.utf8
, replacing en_US.utf8 with whatever locale you want.
您需要将操作系统的语言环境设置为任何 utf8 兼容的语言环境。运行locale -a
以获取您可以使用的语言环境列表,然后执行类似操作update-locale LANG=en_US.utf8
,将 en_US.utf8 替换为您想要的任何语言环境。