Linux – Adding an admin user to a MongoDB

databaselinuxmongodb

I'm using MongoDB 3.0.3, and I've been having issues with creating users.

I created a user on the admin database using db.addUser('admin', '….'). I gave it dbAdminAnyDatabase privilege. The output of the content was a user account in the JSON. db.system.users.find reports (as seen in the image) that the user exists.

However, when I go to db.auth on the admin database. I always get the error "auth failed code 18"

When I try to login from the command line I get the same error, but this time the following message has been put in the logs:

2015-05-25T00:11:47.781-0500 I ACCESS   [conn15] SCRAM-SHA-1 authentication failed for admin on admin from client 127.0.0.1 ; UserNotFound Could not find user admin@admin

What am I doing wrong? I've used the base install from Arch. It's not being started up with auth = true in the config.

enter image description here

Best Answer

The issue I had was that I was using addUser, but that was meant for the mongo 2.x serires. Now you're required to drop that user (which was a forceful thing) and to use createUser and updateUser.

The other thing to note is that Robomongo is only for mongodb 2.x. 3.0 support is coming in the 0.9 releases.

That was incredibly frustrating.

Related Topic