【发布时间】:2018-11-17 15:49:18
【问题描述】:
已经找到了解决方案(see answer below),但我不确定它是否合适;另外,这也可能对其他人有所帮助。
尝试按照文档 (18.2 Creating a Database Cluster) 设置 PostgreSQL,但在 Ubuntu 18.04(内核:4.15.0-22-generic)上出现以下错误:
$ initdb -D /usr/local/pgsql/data
(...)
initdb: invalid locale settings; check LANG and LC_* environment variables
在 Stackoverflow(1、2)上找到了一些相关的答案,但这些都没有解决问题,one on Serverfault 建议重新启动服务,但 PostgreSQL 甚至没有运行。
尝试在我在系统上找到的每个变体中显式传递语言环境,但这些也失败了,
3617 2018/06/07-08:36 initdb -D ~/Downloads/ --locale=en_US.utf8
3618 2018/06/07-08:36 initdb -D ~/Downloads/ --locale=en_US.UTF8
3621 2018/06/07-08:37 initdb -D ~/Downloads/ --locale=en_US.UTF-8
3622 2018/06/07-08:37 initdb -D ~/Downloads/ --locale="en_US.UTF-8"
3623 2018/06/07-08:37 initdb -D ~/Downloads/ --locale="en_US.utf8"
3645 2018/06/07-09:24 initdb -D ~/Downloads/ --locale="en_US.utf8"
与
initdb: invalid locale name <the_option_value_above>
有an Arch Linux forum discussion about this,但没有解决办法。
2018/06/07 1214 更新
我在上面链接了答案,但可能不够明确:我确实看过 locale -a 和 locale(没有列出前者的输出,因为我在下面的尝试中安装了所有这些):
$ locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.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=en_US.UTF-8
什么都试过了,但是没用(每次迭代都重启了终端):
-
https://askubuntu.com/questions/454260/how-to-solve-locale-problem
选择并配置所有语言环境。
$ sudo locale-gen en_US.UTF-8 $ sudo dpkg-reconfigure locales. -
https://github.com/singularityware/singularity/issues/11
都没有
echo "LC_ALL=en_US.UTF-8" >> /etc/environment echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen echo "LANG=en_US.UTF-8" > /etc/locale.conf locale-gen en_US.UTF-8也没有
sudo apt clean sudo apt update sudo apt upgrade sudo apt-get install -y locales language-pack-fi language-pack-en export LANGUAGE=en_US.UTF-8 export LANG=en_US.UTF-8 export LC_ALL=en_US.UTF-8 sudo locale-gen en_US.UTF-8 sudo dpkg-reconfigure locales https://askubuntu.com/questions/162391/how-do-i-fix-my-locale-issue/229512#229512
-
https://askubuntu.com/questions/114759/warning-setlocale-lc-all-cannot-change-locale
(基本上是上面的 github 链接的变体,无论如何都试过了。)
【问题讨论】:
标签: postgresql locale