Tag Archives: MongoDB Update User Error

[Solved] MongoDB Update User Error: Error: not authorized on admin to execute command

MongoDB Update User Error: Error: not authorized on admin to execute command

background

The thing is this: MongoDB weak password vulnerability and high risk, the password must be changed!
Environment: windows, the database is open authentication

report errors

Log in to the database and execute:

use admin
db.changeUserPassword('admin','123456');

report errors:

[Error] Error: not authorized on admin to execute command

Solution:

1. Close mongodb service (Windows service, registered)
2. Start the service without identity authentication:

mongod --dbpath=dbpath

3. Open new CMD

mongo
use admin
db.changeUserPassword('admin','123456');

Normal
4. Restart mongodb service