Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB mongorestore failure: locale::facet::_S_create_c_locale name not valid

I created a dump with mongodump on computer A (ubuntu 12.04 server). I moved it to computer B (ubuntu 12.04 server) and typed:

mongorestore -db db_name --drop db_dump_path

It failed and it reported:

connected to: 127.0.0.1
terminate called after throwing an instance of 'std::runtime_error'
what(): locale::facet::_S_create_c_locale name not valid
Aborted

I've successfully accomplished this operation before and this strange behavior has never occurred. What do I need to do to fix this?

like image 517
Luca Anceschi Avatar asked Sep 30 '13 17:09

Luca Anceschi


2 Answers

On my distro "locale-gen" was not installed and it turned out all I had to do is set the LC_ALL environment variable. so the following command fixed it:

export LC_ALL="en_US.UTF-8" 

hopefully it will help someone else...

like image 86
keisar Avatar answered Sep 18 '22 10:09

keisar


Actually it isn't strictly related to MongoDB. Somehow the language on computer B was not defined correctly. I managed to fix it by typing:

sudo locale-gen en_US en_US.UTF-8
sudo locale-gen it_IT it_IT.UTF-8
sudo locale-gen xx_xx xx_XX.UTF-8 ...
sudo dpkg-reconfigure locales

These commands will generate and configure the needed locales. After those steps mongorestore got back working as usual.

like image 32
Luca Anceschi Avatar answered Sep 20 '22 10:09

Luca Anceschi