What to do if I forget the administrator password

① Comment out the password authentication related information of all config nodes, mongos nodes, and shard node configuration files, examples:

#security:
#  keyFile: /var/lib/mongo/keyFile
  #authorization: enabled

② Restart all mongo nodes

③ Create a new administrator user:

use admin;

db.createUser({user:"用户名",pwd:"密码",roles:[{role:"root",db:"admin"}]});

④ Uncomment password authentication information

Note: The mongos node needs to comment out authorization: enabled, otherwise an error will be reported when starting.

⑤ Restart all mongo nodes

 

Guess you like

Origin blog.csdn.net/yabignshi/article/details/113846489