mongodb 全局初始化失败:BadValue 无效或未设置用户区域设置。请确保 LANG 和/或 LC_* 环境变量设置正确

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27375137/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 20:13:58  来源:igfitidea点击:

Failed global initialization: BadValue Invalid or no user locale set. Please ensure LANG and/or LC_* environment variables are set correctly

mongodbubuntuserver

提问by Momo

I have a problem to generate the locales on the serveur herbert and homer . I run mongo I get the warning

我在 serverur herbert 和 homer 上生成语言环境时遇到问题。我运行 mongo 我收到警告

Failed global initialization: BadValue Invalid or no user locale set. Please ensure LANG and/or LC_* environment variables are set correctly.

When I run

当我跑

dpkg-reconfigure locales

dpkg-reconfigure locales

mongo start successful , then When reboot the server and run mongo i have the same problem.

mongo 启动成功,然后当重新启动服务器并运行 mongo 时,我遇到了同样的问题。

Thank for help

感谢帮助

回答by David

https://askubuntu.com/questions/536875/error-in-installing-mongo-in-virtual-machine:

https://askubuntu.com/questions/536875/error-in-installing-mongo-in-virtual-machine

Looks like your locale settings are broken or non-existent on that VM, or at least that session on that VM. One of MongoDB's dependencies (boost) will fail when a locale is not correctly set (see SERVER-9032). For reference, before the change in SERVER-9032 this problem still happened but looked like this.

Sometimes logging out and back in can fix it (only broken for current session), or you can try running sudo local-gen to make sure generation is successful.

In the meantime, as a workaround to get mongo (or mongod etc.) running, just set your LC_ALL variable manually before starting the program:

看起来您的区域设置在该 VM 上已损坏或不存在,或者至少在该 VM 上的该会话中。当语言环境设置不正确时,MongoDB 的一个依赖项 (boost) 将失败(请参阅 SERVER-9032)。作为参考,在更改 SERVER-9032 之前,此问题仍然存在,但看起来像这样。

有时注销并重新登录可以修复它(仅在当前会话中损坏),或者您可以尝试运行 sudo local-gen 以确保生成成功。

同时,作为让 mongo(或 mongod 等)运行的解决方法,只需在启动程序之前手动设置 LC_ALL 变量:

export LC_ALL=C
mongo