javascript 在MongoDB 3.4中创建用户
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript 在MongoDB 3.4中创建用户相关的知识,希望对你有一定的参考价值。
use admin;
//admin user in the admin database
db.createUser(
{
user: "admin",
pwd: "my_admin_password",
customData: { employeeId: 12345, employeeName: "William Sanchez" },
roles: [ { role: "root", db: "admin" } ]
}
)
//other way of writing admin user in the admin database
db.createUser(
{
user: "admin",
pwd: "my_admin_password",
roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
}
)
//regular user with read and write priviledges on Test database
db.createUser({user: "developer",pwd: "dev_password",roles: [ { role: "readWrite", db: "Test" } ]})
//regular user with read and write priviledges on multiple databases
db.createUser(
{
user: "developer",
pwd: "dev_password",
roles:
[
{ role: "readWrite", db: "Test" },
{ role: "readWrite", db: "OtherCollection" }
]})
以上是关于javascript 在MongoDB 3.4中创建用户的主要内容,如果未能解决你的问题,请参考以下文章
如何使用 PHP 驱动程序在 MongoDB 中创建存储函数
MongoDB 3.4 功能改进一览
在CentOS 7上使用Yum源安装和卸载 MongoDB 3.4
在CentOS 7上使用Yum源安装和卸载 MongoDB 3.4
在CentOS 7上使用Yum源安装和卸载 MongoDB 3.4
mongodb 3.4 集群搭建:分片+副本集