MongoDB 3.7.1 Installation

Source: Internet
Author: User
Tags auth mongodb

cd /usr/local/src/wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.7.1.tgztar -zxvf mongodb-linux-x86_64-3.7.1.tgzmv mongodb-linux-x86_64-3.7.1 /usr/local/mongodbecho "PATH=/usr/local/mongodb/bin:$PATH" >> /etc/profilesource /etc/profilegroupadd mongouseradd -rg mongo mongomkdir -p /data/dbchown -R mongo mongo /usr/local/mongodbcat >> /usr/local/mongodb/bin/mongodb.conf <<EOFfork = trueport = 27017bind_ip = 0.0.0.0dbpath = /data/dblogpath = /data/db/mongodb.logEOF##启动mongod --config /usr/local/mongodb/bin/mongodb.conf
> use adminswitched 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 Installation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.