Learning Activity: Modifying User Passwords - uncaught exception: Error: Updating user failed: User and role names must be either strings or objects :

Hi,

i am trying to update the password and received the below message.

db.updateUser(“globalAdminUser”, { roles : [ { role : “readWrite”, db : “admin” } | “admin”, ], pwd : “6c%dbe&7dc!ee1#d”, mechanisms :[“SCRAM-SHA-1”], }, )

uncaught exception: Error: Updating user failed: User and role names must be either strings or objects :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.updateUser@src/mongo/shell/db.js:1436:11
@(shell):1:1

Most likely the presence of the non JSON character | just before the second "admin" value.

db.updateuser( “readWriteInventoryUser”, { roles: [ {role: “readWrite”, db: “admin”}], pwd : “6c%dbe&7dc!ee1#d”, mechanisms : [“SCRAM-SHA-1”], } )
uncaught exception: SyntaxError: illegal character :
@(shell):1:15

Not sure, but the last comma before the closing brace might be wrong.

The comma is used to separate fields in a JSON document.

i used a wrong function to update password.
db.changeUserPassword() to be used

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.