① 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