Postgresql
將 PostgreSQL 9.4 升級到 9.5:LC_ALL 未設置
我正在嘗試將我的 PostgreSQL 9.4 數據庫升級到 PostgreSQL 9.5,但每次執行時
sudo pg_upgradecluster 9.4 main
都會出現此錯誤:Stopping old cluster... Disabling connections to the old cluster during upgrade... Restarting old cluster with restricted connections... perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = "en_US.UTF-8", 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"). Error: The locale requested by the environment is invalid. Error: Could not create target cluster
但是當我執行時,
locale
我看到LC_ALL
實際設置了:LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 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
我記得在從 PostgreSQL 9.3 升級到 PostgreSQL 9.4 時遇到了同樣的問題,但當時我通過將這一行添加到以下內容來解決這個問題
/etc/environment
:LC_ALL=en_US.UTF-8
但這不再起作用了。
經過多次嘗試解決此問題後,此命令終於對我有用:
export LC_CTYPE=en_US.UTF-8 export LC_ALL=en_US.UTF-8