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

LinuxMongodbUbuntu

Linux Problem Overview


When I run mongo, I get the warning:

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

Linux Solutions


Solution 1 - Linux

you can use the below command on terminal

export LC_ALL=C

Solution 2 - Linux

Generating locales

Missing locales are generated with locale-gen:

locale-gen en_US.UTF-8

Alternatively a locale file can be created manually with localedef:[1]

localedef -i en_US -f UTF-8 en_US.UTF-8

Setting Locale Settings

The locale settings can be set (to en_US.UTF-8 in the example) as follows:

export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
locale-gen en_US.UTF-8
dpkg-reconfigure locales

The dpkg-reconfigure locales command will open a dialog under Debian for selecting the desired locale. This dialog will not appear under Ubuntu. The Configure Locales in Ubuntu article shows how to find the information regarding Ubuntu.

Solution 3 - Linux

vim /etc/default/locale

add to it:

LC_ALL="en_US.UTF-8"

Solution 4 - Linux

Amazon Linux AMI

Permanent solution for ohmyzsh:
$ vim ~/.zshrc

Write there below:

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8

Update changes in current shell by: $ source ~/.zshrc

Solution 5 - Linux

adding the following lines to my /etc/environment file worked

LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8

Solution 6 - Linux

you have to add the missing local lang helper: for me the missing ones where de_LU de_LU.UTF-8 . Mongo 2.6.4 worked wihtout mongo 2.6.5 throw an error on this

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMajid ZandiView Question on Stackoverflow
Solution 1 - LinuxEdsonView Answer on Stackoverflow
Solution 2 - LinuxMajid ZandiView Answer on Stackoverflow
Solution 3 - Linuxliyuan_tView Answer on Stackoverflow
Solution 4 - LinuxdimpiaxView Answer on Stackoverflow
Solution 5 - LinuxTimView Answer on Stackoverflow
Solution 6 - LinuxcwhispererView Answer on Stackoverflow