$ docker exec -it mongo mongo admin
# 创建一个名为 admin,密码为 123456 的用户。
>db.createUser({user:"duser",pwd:"test1mongodb23","roles" : [{"role" : "dbAdmin","db" : "cpeducloud2"},
{"role" : "dbOwner","db" : "cpeducloud2"},{"role" : "readWrite","db" : "cpeducloud2"},
{"role" : "userAdmin","db" : "cpeducloud2"}],"mechanisms" : ["SCRAM-SHA-1","SCRAM-SHA-256"]});
# 尝试使用上面创建的用户信息进行连接。
> db.auth('duser', 'test1mongodb23')