How to log in to a local mongodb 3.2 running on Windows 2012 as super user to create a new user?

Hi All,

I need some urgent help — how do I log in as a super user to a 3.2 mongodb instance running locally on a Windows 2012 host?

I was recently told we have a mongodb instance 3.2 running on a local windows 2012, it is not on Atlas. I need to create a user for development team so they can investigate a production issue.

I can run a command window as an administrator on the host (they just gave me this access). see below:

PS C:\Program Files\MongoDB\Server\3.2\bin> ./mongo
MongoDB shell version: 3.2.19-24-g70faecde6a
connecting to: test

show dbs
2022-09-28T09:07:27.049-0700 E QUERY [thread1] Error: listDatabases failed:{
"ok" : 0,
"errmsg" : "not authorized on admin to execute command { listDatabases: 1.0 }",
"code" : 13
} :


What I need to do is be able to log in as a super user and run below to create a new read only user:

db.createUser({user: “newreadonlyuser”, pwd: “newpassword”, roles: [{role: “readAnyDatabase”, db: “ourdb”}]})

PS. I was given a user/pass that I can use to login to make changes on the above database “ourdb”, but it appears it has no privilege to create a new user.

Any help would be highly appreciated!!



Hi @Erin_Bao welcome to the community!

In most cases if you have admin access to the machine the mongod process is running at, you can run mongod without the --auth parameter to basically make the server run without enforcing auth. In this state, you should be able to create the user, or do any other administration task.

Please make sure that while the mongod is in this no-auth state, it’s safe from any network exposure or any other potential intrusion, since anyone can connect to it and be an admin in this state. Once you’re done, you should re-enable --auth again as soon as possible.

Before doing this I would recommend you to take a backup, and consider upgrading to a supported version (MongoDB 3.2 series is out of support since September 2018).

Best regards

1 Like