createUser 在运行命令的数据库上创建新用户。 如果用户存在,createUser命令将返回重复用户错误。 提示 在mongosh中,该命令也运行通过db.createUser()辅助方法运行。 辅助方法对mongosh用户来说很方便,但它们返回的信息级别可能与数据库命令不同。如果不追求方便或需要额外的返回字段,请使用数据库命令。
db.createUser({user:"bkUser",pwd:"123",roles:[{role:"backup",db:"admin"}]}) 注:新建backup账户时,roles里面的db必须是admin,要不然会报错,如下: >db.createUser({user:"bkUser2",pwd:"123",roles:[{role:"backup",db:"test"}]}) Error: couldn't add user: No role named backup@test 1....
MongoDB Manual / Self-Managed Deployments / Security / Authentication / Users With access control enabled, users are required to identify themselves. You have to grant a user one or moreroles. A role grants a userprivilegesto perform certainactionson MongoDBresources. ...
Create User:Create user is a method that was used to create a new user in MongoDB. Using create user method, we have to create new users as per the operation specified in MongoDB. User or user_info: The typeof user parameter is a document in creating the user method. This parameter ...
user: "mongo-root", pwd: "passw0rd", roles: [ { role: "root", db: "admin" } ] } ) Create User For Database Switch to the database in which you would like to create a common user: > usemy-database Createmy-userwithreadWritepermissions onmy-database: ...
要在MongoDB部署中创建用户,请连接到部署,然后使用db.createUser()方法或createUser命令添加用户。 > use admin > db.createUser( { user:"root", pwd:"123456", roles:[{role:"root",db:"admin"}] } ) 1. 2. 3. 4. 5. 6. 7. 8.
environment:-MONGO_INITDB_ROOT_USERNAME=user - MONGO_INITDB_ROOT_PASSWORD=password-MONGO_INITDB_DATABASE=test more explanation at:https://stackoverflow.com/a/42917632/1069610 This is how I do it, my requirement was to bring up a few containers along with mongodb, the other containers expect ...
将security.authorization值从enabled改为disabled 2.3 启动MongoDB /usr/local/mongodb/bin/mongod -f /usr/local/mongodb/mongod.conf 3、验证 use admindb.createUser({user:"admin",pwd:"shenz2024",roles:[{role:"root",db:"admin"}]});
use db2 db.createUser( { user: "mongoUser", pwd: "mongo_pass", roles: [ { role: "read", db: "myDB" } ] } ) The Error: The error you are getting is because that you have not authenticated yourself as a user administrator, before creating new users. To un...
MongoDB使用命令创建用户权错误分析 错误一:权限不够Error:couldn't add user:command createUser requires authentication、 解决方案:先使用超级管理员登录,再进行其他数据库用户创建的创建。