2011-12-02 92 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 
相關問題