Cant access mongo terminal in Digital Ocean

  • Hi friends
    I install ubuntu 12.04LTS on my droplet. I install 14.04LTS before this on my droplet and install NodeBB on it. The problem I faced was. When I tried to run "mongo" command in the terminal. When I type mongo on the command line.I get the following error :

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

    • perl: warning: Setting locale failed.
      perl: warning: Please check that your locale settings:
      LANGUAGE = (unset),
      LC_ALL = (unset),
      LC_CTYPE = "UTF-8",
      LANG = "en_US.UTF-8"
      are supported and installed on your system.
      perl: warning: Falling back to the standard locale ("C").
      locale: Cannot set LC_CTYPE to default locale: No such file or directory
      locale: Cannot set LC_ALL to default locale: No such file or directory
      Generating locales...
      en_AG.UTF-8... done
      en_AU.UTF-8... done
      en_BW.UTF-8... done
      en_CA.UTF-8... done
      en_DK.UTF-8... done
      en_GB.UTF-8... done
      en_HK.UTF-8... done
      en_IE.UTF-8... done
      en_IN.UTF-8... done
      en_NG.UTF-8... done
      en_NZ.UTF-8... done
      en_PH.UTF-8... done
      en_SG.UTF-8... done
      en_US.UTF-8... up-to-date
      en_ZA.UTF-8... done
      en_ZM.UTF-8... done
      en_ZW.UTF-8... done
      Generation complete.

    So I thought this error was due to the ubuntu version so I changed it to 12.04LTS. But now I still face the same problem. What can I do to overcome this problem? Has anyone faced this problem before?
    Thank you

  • GNU/Linux Admin

    Can you let us know how you installed MongoDB?

  • @julian
    Hi friend. Thanks for the reply.
    I followed this tutorial
    Mongo Setup

  • GNU/Linux Admin

    In step 4, can you please list the commands you ran?

  • @gvimlan said:

    Mongo Setup

    I ran only "sudo apt-get install -y mongodb-org" command

  • you've set-up UTF-8 as LC_CTYPE, it has to be sth. like en_US.UTF-8 instead since there is no locale called just UTF-8.

    check your /etc/locale.conf and /etc/default/locale (if existent) or print the contents here.

  • @frissdiegurke Hi friend. I wasn't able to find the file on /etc/locale.conf
    But the file at /etc/default/locale has the below code:

  • anything like within ~/.profile?
    does locale and env | grep LC_CTYPE display the same assignment of LC_CTYPE?

    try running export LC_CTYPE=en_US.UTF-8 && mongo in order to figure out whether this is the correct problem we're after.

  • GNU/Linux Admin

    @frissdiegurke Thanks for tagging in 😄

  • @frissdiegurke
    export LC_CTYPE=en_US.UTF-8 && mongo method worked and it was okay. But when I logout and log in back.

    I tried mongo and got this error back.

    perl: warning: Setting locale failed.
    perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_CTYPE = "UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
    perl: warning: Falling back to the standard locale ("C").

  • @gvimlan yes, the export command only sets the environment-variable LC_CTYPE for that session. it's just for testing whether I've determined the correct problem.

    So you now know the problem is definitely a wrong assigned environment-variable.
    Because I don't use ubuntu at all I don't know where they typically set such variables.
    You may also check the /etc/environment file for LC_CTYPE (cat /etc/environment | grep LC_CTYPE for example) or ~/.bashrc or any other file starting with ~/.bash.
    Otherwise it doesn't look like a standard-file for environment-setup does this assignment.

    If you don't find that assignment as a not-the-cleanest fix you should overwrite it yourself by adding LC_CTYPE=en_US.UTF-8 into /etc/default/locale or /etc/locale.conf or (user-scope) export LC_CTYPE=en_US.UTF-8 into ~/.profile.

    For further information about where/when/whatever of environment-variables within ubuntu take a look at

  • @frissdiegurke
    Hey mate. Thanks for the advice.
    Should I add LC_CTYPE=en_US.UTF-8 or LC_CTYPE="en_US.UTF-8" into .etc/default/locale? Is the " " necessary?

  • Plugin & Theme Dev

    @gvimlan it's not necessary but doesn't make a difference in that case 😉

  • @frissdiegurke
    Thanks mate 🙂

  • @frissdiegurke Hey mate

    I installed nodebb and mongodb based on this tutorial.
    [Installing method]
    Everyone went well. When i typed mongo and type show databases. I m getting the following error. Does this mean I m not having root access. How do I login to the database?

    2015-03-31T09:04:42.214-0400 E QUERY Error: listDatabases failed:{
    "ok" : 0,
    "errmsg" : "not authorized on admin to execute command { listDatabases: 1.0 }",
    "code" : 13
    at Error (<anonymous>)
    at Mongo.getDBs (src/mongo/shell/mongo.js:47:15)
    at (src/mongo/shell/utils.js:630:33)
    at shellHelper (src/mongo/shell/utils.js:524:36)
    at (shellhelp2):1:1 at src/mongo/shell/mongo.js:47

  • Since I did never create any additional mongodb-users (I have no running systems) I can't help you with that pretty much.

    Maybe you've run db.createUser without use nodebb before in that very same session (I don't know to which db they get bound in this case)...

    Try show users (within a clean mongo session) and if a nodebb user exists I'd recommend following this official guide.

  • @frissdiegurke
    Hi mate
    I m not sure how things are working. But I created the nodebb forum and everything seems to be storing in the database. How do I look into to the content saved in the database? And will the content being saved in the database I specified or the default one?
    Everything seems to be good except the database part. Is there I can read where does Nodebb save its data and stuff?

    Thank you

  • Plugin & Theme Dev

    If you look into the config.json within your NodeBB root-directory you should get some information about how NodeBB tries to access the database (the way you specified within ./nodebb setup)

    If you'd be able to manage your permission-problem you could run mongo and within use nodebb and show collections for each of the collections you may run db.COLLECTION.find() to get a plain list of the JSONs within.

  • @frissdiegurke
    Hey mate 🙂

    Why do I get the error below:
    2015-04-01T07:02:19.625-0400 E QUERY Error: couldn't add user: not authorized on nodebb to execute command { createUser: "user, roles: [ "readWrite" ], digestPassword: false, writeConcern: { w: "majority", wtimeout: 30000.0 } }
    at Error (<anonymous>)
    at DB.createUser (src/mongo/shell/db.js:1066:11)
    at (shell):1:4 at src/mongo/shell/db.js:1066

    I get error like this whenever i tried to do sometime like show collections or show databases

    Why do i get this error?

Suggested Topics

| | | |