2011-12-02 94 views
19

所以我走过GeoDjango内置教程和我卡在此错误消息:为PostgreSQL和PostGIS的变化LC_CTYPE使用

[email protected]:~$ 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. 

我GOOGLE了,看了一些Ubuntu的文档,但无济于事。任何有识之士将不胜感激!

我使用默认的Vagrant Box lucid 32来测试我的设置。

回答

13

最好只指定数据库的区域设置,并从中找出编码。因此,使用类似

createdb --locale=en_US.utf8 template_postgis 
+13

我居然落得这样做是CREATEDB -E UTF8 -T template0中--locale = en_US.utf8 template_postgis –

+0

'--locale =的en_US.UTF-8'作为的PostgreSQL 9.4.5 –

2

您需要将操作系统的语言环境设置为任何与utf8兼容的语言环境。运行locale -a以获取可以使用的区域设置列表,然后执行类似update-locale LANG=en_US.utf8的操作,用所需的任何区域设置替换en_US.utf8。

4

否则,试试这个,当您登录到PostgreSQL:

create database databse_name with owner database_owner encoding='UTF-8'lc_collate='en_US.utf8' lc_ctype='en_US.utf8' template template0; 
+1

加上1条,添加template0 – Erik

9

-E UTF8和--locale = en_US.utf8都需要

$ createdb -E UTF8 -T template0 --locale=en_US.utf8 template_postgis 
相关问题