maybug

导航

mongodb配置和启动创建管理员

root@hecs-200775:/usr/local/mongodb/bin# ./mongod --config /usr/local/mongodb/etc/mongodb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 772134
child process started successfully, parent exiting

mongodb 启动

 

root@hecs-200775:/usr/local/mongodb/bin# netstat -tlnup | grep mongod
tcp        0      0 127.0.0.1:27017         0.0.0.0:*               LISTEN      772134/./mongod

查看mongodb 进程

> use admin
switched to db admin 
> db.createUser({ user: "admin", pwd: "123456", roles: [{ role: "userAdminAnyDatabase", db: "admin" }] })

Successfully added user: {
        "user" : "admin",
        "roles" : [
                {
                        "role" : "userAdminAnyDatabase",
                        "db" : "admin"
                }
        ]
}

创建管理员账号

db.createUser({user: "root",pwd: "123456", roles: [ { role: "root", db: "admin" } ]})

Successfully added user: {
"user" : "root",
"roles" : [
{
"role" : "root",
"db" : "admin"
}
]
}

创建root账号

posted on 2023-03-31 16:13  maybug  阅读(43)  评论(0编辑  收藏  举报