远程服务器上的 Postgres 语言环境错误

Postgres locale error on remote server

我使用的是来自 Digital Ocean 的远程服务器,设置了 Ubuntu 14.04,Rails,并且遇到缺少区域设置的问题。我用谷歌搜索了这个问题并尝试了它们,但对我不起作用。

例子

sudo locale-gen en_US en_US.UTF-8
sudo dpkg-reconfigure locales 

尝试创建新的 Postgres 用户时收到错误

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C")

我的区域设置

locale: Cannot set LC_CTYPE to default locale: No such file or   directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE=UTF-8
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

您的语言似乎没有设置。

你可以试试

export LANGUAGE="en_US.UTF-8"
echo 'LANGUAGE="en_US.UTF-8"' >> /etc/default/locale
echo 'LC_ALL="en_US.UTF-8"' >> /etc/default/locale

这篇关于如何 configure locale in Ubuntu 的好文章。


编辑:我现在注意到它是关于数字海洋的。尝试改为编辑环境

gksudo gedit /etc/environment

并添加 LANGUAGE="en_US.UTF-8"LC_ALL="en_US.UTF-8"。希望对你有帮助。

运行之前进入locales问题:

http://andreas.scherbaum.la/blog/archives/272-locales-on-Ubuntu.html