扯基巴淡的MONGO查询实例

>useadmin

switchedtodbadmin

>db.createUser({user:“root”,pwd:“pass”,roles:[{role:“userAdminAnyDatabase

”db.createUser({user:“root”,pwd:“pass”,roles:[{role:“userAdminAnyDatabase

”,db:“admin”}],mechanisms:[“SCRAM-SHA-1”]})

2019-07-17T10:59:00.894+0800EQUERY[js]SyntaxError:illegalcharacter@(sh

ell):1:20

>db.createUser({user:“root”,pwd:“pass”,roles:[{role:“userAdminAnyDatabase

”db.createUser({user:“root”,pwd:“pass”,roles:[{role:“userAdminAnyDatabase

”,db:“admin”}],mechanisms:[“SCRAM-SHA-1”]})

2019-07-17T10:59:20.478+0800EQUERY[js]SyntaxError:illegalcharacter@(sh

ell):1:20

>db.createUser({user:"root",pwd:"pass",roles:[{role:"userAdminAnyDatabase",db:"

admin"}],mechanisms:["SCRAM-SHA-1"]})

Successfullyaddeduser:{

"user":"root",

"roles":[

{

"role":"userAdminAnyDatabase",

"db":"admin"

}

],

"mechanisms":[

"SCRAM-SHA-1"

]

}

>whereismongod

2019-07-17T11:02:56.375+0800EQUERY[js]SyntaxError:missing;beforestate

ment@(shell):1:8

>showdbs

admin0.000GB

config0.000GB

local0.000GB

>showusers;

{

"_id":"admin.root",

"userId":UUID("2afa70f7-c5c5-4738-b187-6208d2cdca1c"),

"user":"root",

"db":"admin",

"roles":[

{

"role":"userAdminAnyDatabase",

"db":"admin"

}

],

"mechanisms":[

"SCRAM-SHA-1"

]

}

>db.runoob.insert({"name":"newchapt1"})

WriteResult({"nInserted":1})

>showdbs

admin0.000GB

config0.000GB

local0.000GB

>db.admin.insert({"name":"seetomorrow"})

WriteResult({"nInserted":1})

>showdbs

admin0.000GB

config0.000GB

local0.000GB

>showtables

admin

runoob

system.users

system.version

>select*fromadmin

2019-07-17T11:15:18.071+0800EQUERY[js]SyntaxError:missing;beforestate

ment@(shell):1:14

>db.collection.find().pretty()

>db.admin.find().pretty()

{"_id":ObjectId("5d2e92a8f50738b56bf09a93"),"name":"seetomorrow"}

>

创建用户,建表,查询。

基本任务完成。

照着搞吧。

https://www.runoob.com/mongodb/mongodb-query.html

相关推荐