Home Ask Login Register

Developers Planet

Your answer is one click away!

Willmore February 2016

How to rename a user in MongoDB?

There is a user in database, this user should be renamed. How to rename the user? The MongoDB user management reference has method db.updateUser but I don't see how to set a new name for the user. How to update the username? ty

     customData : { <any information> },
     roles : [
               { role: "<role>", db: "<database>" } | "<role>",
     pwd: "<cleartext password>"
    writeConcern: { <write concern> }


Alex Blex February 2016

Did you try to update the user?

db.system.users.update({"user":"oldname"}, {$set:{"user":"newname"}})

This command requires root access to admin database.

Post Status

Asked in February 2016
Viewed 2,105 times
Voted 5
Answered 1 times


Leave an answer

Quote of the day: live life