0

I have been using MLab and MongoAtlas successfully for a project I'm working on. Now I'm trying to migrate the DB to local storage so that the software can write and store data without needing internet access.

The problem has come up after the initial install on an rPi3B+ running openSuse Tumbleweed. I installed it, ran mongod, then mongo. Once in the shell I ran a few simple things like show dbs without a problem.

Then I ran these two lines from this tutorial (for ubuntu 18.04): https://www.howtoforge.com/tutorial/install-mongodb-on-ubuntu/

sudo systemctl start mongodb
sudo systemctl enable mongodb

Note: the tutorial specifies mongod but that didn't work until using mongodb

After this I run into an authorization problem when using show dbs and db.createUser().

"errmsg" : "not authorized on admin to execute command { listDatabases: 1.0, $db: \"admin\" }",
"code" : 13,
"codeName" : "Unauthorized"

Even when running sudo mongo to enter the shell this is still a problem. What about that tutorial changed my ability to use the shell? Also, what would be the better way to run mongo as a service on boot up?

Thanks!

  • I was just going over the openSuse Wiki: en.opensuse.org/MongoDB Created a user prior to enabling the service, confirmed login as the wiki shows but then when I enable the service I can't log in with that user. What's happening with running it as a service? – Eru Jan 6 at 3:12
  • What is MongoDB version(x,y,z)? – Md Haidar Ali Khan Jan 7 at 10:43
  • what is showing the status of MongoDB through (sudo systemctl status mongod) – Md Haidar Ali Khan Jan 7 at 10:44
  • what I ended up having to do was run mongo -u admin -p admin123 --authenticationDatabase admin. Still can't figure out what's going on and am having trouble connecting to mongo locally. Went back to using atlas for the time being. – Eru Jan 21 at 4:42
  • Check the "Role" of the user and "authenticate" the user. – Md Haidar Ali Khan Jan 21 at 6:23
0

As I am able to see that you are getting the following error

"errmsg" : "not authorized on admin to execute command { listDatabases: 1.0, $db: \"admin\" }",
"code" : 13,
"codeName" : "Unauthorized"

As per MongoDB documentation here To authenticate as a user, you must provide a username, password, and the authentication database associated with that user.

To authenticate using the mongo shell, either:

  1. Use the mongo command-line authentication options (--username, --password, and --authenticationDatabase) when connecting to the mongod or mongos instance, or
  2. Connect first to the mongod or mongos instance, and then run the authenticate command or the db.auth() method against the authentication database.

Note: MongoDB Atlas natively supports authentication via LDAP. Atlas automatically syncs with your LDAP server and makes it easy for your users to authenticate with their existing credentials

For further your ref here and here

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.