MongoDB(windows)基础教程1用户创建和切换 |
您所在的位置:网站首页 › window如何创建用户 › MongoDB(windows)基础教程1用户创建和切换 |
MongoDB(windows)基础教程1用户创建和切换
参考视频点击进入
参考文档点击进入
接着上篇
在cdm中运行 C:\Users\Administrator>cd C:\Program Files\MongoDB\Server\4.4\bin C:\Program Files\MongoDB\Server\4.4\bin>mongo 之后… 创建管理员 创建超级管理员 > use admin switched to db admin > show tables system.version > db.createUser({'user':'root','pwd':'1394006513','roles':[{'role':'root','db':'admin'}],'customData':{'infomation':'first mongodb user'}}) Successfully added user: { "user" : "root", "roles" : [ { "role" : "root", "db" : "admin" } ], "customData" : { "infomation" : "first mongodb user" } } 查看用户方法1 > use admin switched to db admin > show users { "_id" : "admin.root", "userId" : UUID("72d70640-4c84-4fa5-b05d-710d9e1cc4a0"), "user" : "root", "db" : "admin", "customData" : { "infomation" : "first mongodb user" }, "roles" : [ { "role" : "root", "db" : "admin" } ], "mechanisms" : [ "SCRAM-SHA-1", "SCRAM-SHA-256" ] } 查看用户方法2 > show tables system.users system.version > db.system.users.find() { "_id" : "admin.root", "userId" : UUID("72d70640-4c84-4fa5-b05d-710d9e1cc4a0"), "user" : "root", "db" : "admin", "credentials" : { "SCRAM-SHA-1" : { "iterationCount" : 10000, "salt" : "Cz2u3g5bJgjOaa/4CpMWzg==", "storedKey" : "k8ndjxkE2GagW1Mxm+oreN0VKyU=", "serverKey" : "mlbc+NTY5B3TfHBjwfQGlTZ2PFM=" }, "SCRAM-SHA-256" : { "iterationCount" : 15000, "salt" : "/RIXu+s51lxeUyhoxdbkHx+o99uX/qo8xaHfBg==", "storedKey" : "ZjrMkUM+IbrOnIMWPzMYer5rcVBkv6wdtrDd8z0fBrI=", "serverKey" : "SzprXkWFi8PjdtVyHHbcAubTYmcasLYY334oHP6flqU=" } }, "customData" : { "infomation" : "first mongodb user" }, "roles" : [ { "role" : "root", "db" : "admin" } ] } 修改管理员信息之后要重启 > use admin switched to db admin > db.shutdownServer() server should be down... > quit() 修改配置文件(验证登录)(踩坑踩了半天) 1.修改配置文件
别的也没啥说的 ok,那就这样吧~ 欢迎各位大佬留言吐槽,也可以深入交流~ |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |