MongoDB.live, free & fully virtual. June 9th - 10th. Register Now MongoDB.live, free & fully virtual. June 9th - 10th. Register Now

db.getUsers() show an empty array

Hi All,

I created a user with the below command by switching to admin db. But when I switch back to the user db and try to list the users, it shows an empty array. Any idea on why the get.Users() shows an empty array.

users > db.createUser({user:'arun', pwd:'hidden', roles:['readWriteAnyDatabase']})

createrUser creates a new user for the database on which the method is run.

So, switch back to admin database and type db.getUsers(), you should see the user you created.