BadValue Invalid or no user locale set. Please ensure LANG and/or LC_* environment variables are set correctly
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.
Failed global initialization: BadValue Invalid or no user locale set. Please ensure LANG and/or LC_* environment variables are set correctly
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:
export LC_ALL=C
mongo
PostgreSQL's `initdb` fails with invalid locale settings; check LANG and LC_* environment variables
From this thread:
initdb -D <your_data_location> --no-locale --encoding=UTF8
where
--locale=LOCALE set default locale for new databases
--no-locale equivalent to --locale=C
There are caveats (see warning below), but an all-utf8 database can be created using template0
(see 21.3. Template Databases).
From the client (psql
):
postgres=# create database test LC_COLLATE "en_US.UTF-8" LC_CTYPE "en_US.UTF-8" template template0;
Or via createdb
:
createdb --lc-collate="en_US.UTF-8" --lc-ctype="en_US.UTF-8" --template="template0" test2
Check:
$ psql
psql (10.3)
Type "help" for help.
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | C | C |
template0 | postgres | UTF8 | C | C | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | C | C | =c/postgres +
| | | | | postgres=CTc/postgres
test | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
test2 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
WARNING: This is probably not the correct solution and the workaround above is just that, a workaround.
Note the "Collate" and "Ctype" fields below in a database created with the above solution and this may cause issues, because "The results of comparisons between strings depends on LC_CTYPE
. In practice, the most visible effect is the sort order." (see DBA StackExchange thread). This is also confirmed on the PostgreSQL mailing list (see this thread about this issue on a database in production). Probably the easiest way to solve this would be re-initializing/recreating the database.
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+---------+-------+-----------------------
postgres | postgres | UTF8 | C | C |
template0 | postgres | UTF8 | C | C | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | C | C | =c/postgres +
| | | | | postgres=CTc/postgres
(3 rows)
What is wrong with my mongodb?
Install swedish locale.
sudo apt-get install language-pack-sv
initdb.bin: invalid locale settings; check LANG and LC_* environment variables
The issue solved when i used the following commands
LC_ALL="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
For Unix you have to be
export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
Whenever i open a man page in ubuntu, i see this warning
Typing the command locale -a
will show which locales are available on your system.
Typing the command locale
will show how your locale variables are currently assigned.
See this wiki page for an explanation of locale on Ubuntu including how to set it correctly
Can't use mongo command, shows command not found on mac
You need to add the path to "mongo" to your terminal shell.
export PATH=$PATH:/usr/local/mongodb/bin
Did you do the last step with paths.d? If so, try restarting your terminals.
Do you have a good reason for using 1.8.5? The current stable is 2.0.4, and it has many useful upgrades from 1.8.x
Related Topics
Where Is Hardware Timer Interrupt
Linux Wildcard Usage in Cp and Mv
Sorting Scientific Number with Unix Sort
How to Control Backlight by Terminal Command
How to Make a Public HTML Folder in Ubuntu
How to See Top Processes Sorted by Actual Memory Usage
When to Use Kernel Threads VS Workqueues in the Linux Kernel
Fuzzy File Search in Linux Console
How to Record What Process or Kernel Activity Is Using the Disk in Gnu/Linux
Bash Script Read All the Files in Directory
Link a Static Library to a Shared One During Build
How to Exclude a Folder When Performing File Operations I.E. Cp, Mv, Rm and Chown etc. in Linux
Cmake Doesn't Know Where Is Qt4 Qmake
Ubuntu - Run Command on Start-Up with "Sudo"
Is There an Equivalent to Com on *Nix Systems ? If Not, What Was the *Nix Approach to Re-Usability