码迷,mamicode.com
首页 > 数据库 > 详细

mongodb 3.7.1 安装

时间:2018-01-16 12:13:13      阅读:410      评论:0      收藏:0      [点我收藏+]

标签:mongodb   get   /etc   pad   too   bind   127.0.0.1   use   groupadd   

cd /usr/local/src/ wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.7.1.tgz tar -zxvf mongodb-linux-x86_64-3.7.1.tgz mv mongodb-linux-x86_64-3.7.1 /usr/local/mongodb echo "PATH=/usr/local/mongodb/bin:$PATH" >> /etc/profile source /etc/profile groupadd mongo useradd -rg mongo mongo mkdir -p /data/db chown -R mongo mongo /usr/local/mongodb cat >> /usr/local/mongodb/bin/mongodb.conf <<EOF fork = true port = 27017 bind_ip = 0.0.0.0 dbpath = /data/db logpath = /data/db/mongodb.log EOF ##启动 mongod --config /usr/local/mongodb/bin/mongodb.conf
> use admin
switched to db admin
> db.createUser({user:"admin",pwd:"password",roles:["root"]})
Successfully added user: { "user" : "admin", "roles" : [ "root" ] }
> db.getCollectionNames()
[ "system.users", "system.version" ]

echo auth = true  >>  /usr/local/mongodb/bin/mongodb.conf      ##重启mongodb

##登录账号密码
> db.auth("admin", "password")
#创建库
> use autoops  

> db.createUser({user: "autoops", pwd: "autoops", roles: [{ role: "dbOwner", db: "autoops" }]})
Successfully added user: {
        "user" : "autoops",
        "roles" : [
                {
                        "role" : "dbOwner",
                        "db" : "autoops"
                }
        ]
}
mongo  -u admin -p password  127.0.0.1:27017/admin

mongodb 3.7.1 安装

标签:mongodb   get   /etc   pad   too   bind   127.0.0.1   use   groupadd   

原文地址:http://blog.51cto.com/hequan/2061444

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!