MongoDB addUser Not Working

I am in the beginning stages of getting familiar with MongoDB as I will be using it in some near future projects.  I have been curious about it for a while, particularly since it seems to buck the idea of your standard data constraint requirements.  Back in my day (yup, I think that statement qualifies me for being old), my college courses always taught that 3NF (3rd Normal Form) was the only way.  Then I started hearing about a new way for certain data scenarios.

While walking though some basics within MongoDB, I ran into an issue with creating users with the db.addUser(document) command.  It would create the user, but when I tried to login as that user I would receive the following:
I retraced my steps to create the user and you can see the db.addUser is deprecated when I ran it, but I moved forward with it as the documentation I was using used it.  So I assumed that while it may be deprecated it would still work as expected:

I created this user over a week prior to me trying to log in, so I had completely forgotten about the deprecated message.  I asked one of our other developers here at work and he mentioned the deprecated command, and I immediately looked up the current command.  Now as you can see above, when I run the command it yells about it being deprecated.  So, to be honest, I am not really sure how I got the user into the database security, but what I do know it, the user document was way off.

So, all that is to say, if you run into the above login error, make sure you use the newer, non-deprecated db.createUser(user, writeConcern) command.



Crafted with love using:Crafted with love, using Desk!

2 Replies to “MongoDB addUser Not Working”

Leave a Reply