在浏览器中输入网址:http://localhost:27017/ 。
如果服务启动成功会看到以下一段话:
It looks like you are trying to access MongoDB over HTTP on the native driver port.
在bin目录下输入如下命令:
./mongo
MongoDB shell version v4.0.9
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
> db
test
> use yapi
switched to db yapi
> db.auth("admin","admin")
Error: Authentication failed.
0
#####手动添加admin账户
> db.createUser( { user: "admin", pwd: "admin", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] } )
Successfully added user: {
"user" : "admin",
"roles" : [
{
"role" : "userAdminAnyDatabase",
"db" : "admin"
}
]
}
> db.auth("admin","admin")
1