如何解決Perl:警告:設置區域設置失敗

今天,在我的ubuntu服務器上,我執行了以下命令來重新配置MariaDB服務器。

sudo dpkg-reconfigure mariadb-server-10.0

屏幕上出現警告。

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
 LANGUAGE = "en_HK:en",
 LC_ALL = (unset),
 LC_PAPER = "zh_CN.UTF-8",
 LC_ADDRESS = "zh_CN.UTF-8",
 LC_MONETARY = "zh_CN.UTF-8",
 LC_NUMERIC = "zh_CN.UTF-8",
 LC_TELEPHONE = "zh_CN.UTF-8",
 LC_IDENTIFICATION = "zh_CN.UTF-8",
 LC_MEASUREMENT = "zh_CN.UTF-8",
 LC_TIME = "zh_CN.UTF-8",
 LC_NAME = "zh_CN.UTF-8",
 LANG = "en_HK.UTF-8"
 are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_HK.UTF-8").
locale: Cannot set LC_ALL to default locale: No such file or directory

它說設置語言環境失敗。

解決方案

首先列出用戶的當前語言環境設置。

$ locale
LANG=en_HK.UTF-8
LANGUAGE=en_HK:en
LC_CTYPE="en_HK.UTF-8"
LC_NUMERIC=zh_CN.UTF-8
LC_TIME=zh_CN.UTF-8
LC_COLLATE="en_HK.UTF-8"
LC_MONETARY=zh_CN.UTF-8
LC_MESSAGES="en_HK.UTF-8"
LC_PAPER=zh_CN.UTF-8
LC_NAME=zh_CN.UTF-8
LC_ADDRESS=zh_CN.UTF-8
LC_TELEPHONE=zh_CN.UTF-8
LC_MEASUREMENT=zh_CN.UTF-8
LC_IDENTIFICATION=zh_CN.UTF-8
LC_ALL=

然後一一生成這些語言環境。

$ sudo locale-gen "en_HK.UTF-8"
Generating locales...
 en_HK.UTF-8... up-to-date
Generation complete.
$ sudo locale-gen "zh_CN.UTF-8"
Generating locales...
 zh_CN.UTF-8... done
Generation complete.

最後重新配置語言環境。

$ sudo dpkg-reconfigure locales
Generating locales...
 en_HK.UTF-8... done
 en_US.UTF-8... done
 zh_CN.UTF-8... up-to-date
Generation complete.

現在,區域設置問題已解決。

Sidebar