由于语言的一些问题,ubuntu的bash会报warning: setlocale: LC_ALL: cannot change locale (zh_CN.UTF-8),这在我安装pg时,导致了启动失败。

sudo -u postgres psql -c "SELECT version();"
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = "zh_CN.UTF_8",
LC_CTYPE = "UTF-8",
LC_TERMINAL = "iTerm2",
LC_TERMINAL_VERSION = "3.4.8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (zh_CN.UTF_8)
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

解决办法:

vim /etc/profile

在最后一行加上

export LC_ALL=C;unset LANGUAGE

然后使它生效

source /etc/profile

即可。


扫码手机观看或分享: