强制执行 RBAC 后,客户端在连接到 mongos 时必须指定 --username、--password 和--authenticationDatabase 才能访问集群资源。 每个集群都有自己的集群用户。这些用户不能用于访问单个分片。 有关向已启用 RBAC 的 MongoDB 部署中添加用户的教程,请参阅在自管理部署中启用访问控制。
另外,也可以使用mongosh的命令行选项--username、--password、--authenticationDatabase和--authenticationMechanism在连接mongosh时指定身份验证凭证: mongosh --username"myTestDBUser"--password --authenticationDatabasetest--authenticationMechanism SCRAM-SHA-256 ...
# mongo --host 10.10.10.11 --port 27018 --authenticationDatabase admin -u root -p 123456myrs:SECONDARY> show dbs#查看数据库,这里不能查看是因为默认副本节点不能查询数据,需要开启查询权限uncaught exception: Error: listDatabases failed:{"topologyVersion": {"processId": ObjectId("5fb38ca9ae9c791f...
#spring.data.mongodb.uri=mongodb://localhost:27017/neptunespring.data.mongodb.username=nucRoot spring.data.mongodb.password=ENC(AwrUSlL/w4Muk=) spring.data.mongodb.host=localhost spring.data.mongodb.port=27017spring.data.mongodb.database=uranus spring.data.mongodb.authentication-database=admin 相...
$ mongosh -u Kunwu --authenticationDatabase admin 1. -u/--user:指定用户名 --authenticationDatabase:指定验证数据库。验证数据库,就是创建用户时所处的那个数据库。 然后命令行中会提示你输入密码: 回车确认即可登录: 也可以直接在命令行通过-p/--password来输入密码: ...
$ mongosh -u Kunwu --authenticationDatabase admin -u/--user:指定用户名 --authenticationDatabase:指定验证数据库。验证数据库,就是创建用户时所处的那个数据库。 然后命令行中会提示你输入密码: 回车确认即可登录: 也可以直接在命令行通过-p/--password来输入密码: ...
mongo --port 27017 -u "myUserAdmin" --authenticationDatabase "admin" -p 1. 当提示时输入你的密码,在本示例中是:abc123。 在连接后进行身份认证 连接mongo shell到mongod: mongo --port 27017 1. 在这个mongo shell 中,切换到认证数据库(在这个例子中是:admin),然后使用db.auth(, )方法进行身份认证...
// 客户端连接$ mongo// 切换到admin库>use admin// 创建用户>db.createUser({user:"myUserAdmin",pwd:"abc123",roles:[{role:"userAdminAnyDatabase",db:"admin"}]})// 登陆, 只有登陆后才能进行其他操作>db.auth("myUserAdmin","abc123")// 授予角色, 可以根据前面的介绍以及个人需要来授予>db.gra...
--dir=<directory>恢复数据的目录路径--drop 在恢复数据前删除已存在的集合--ssl 使用SSL连接到MongoDB服务器--sslCAFile=<filename>SSLCA证书文件路径--sslPEMKeyFile=<filename>SSLPEM证书文件路径--sslPEMKeyPassword=<password>SSLPEM证书密码--authenticationDatabase=<database>认证数据库的名称--gzip 恢复...
mongo10.66.187.127:27017/singer -u mongouser -p thepasswordA1 --authenticationDatabase admin 如图: MONGODB-CR 认证(rwuser) 请注意,只有默认用户 rwuser 使用 MONGODB-CR 认证,其 shell 连接参数需要指明认证方式为 MONGODB-CR,示例如下: ...