MongoDB (i)

Source: Internet
Author: User

#mongodb安装 (3.4.0)

#下载安装包, unzip

Mkdir/data/mongodb

Cd/data/mongodb

mkdir Log conf Data bin

Vim conf/mongod.conf

#添加一下内容

port=27017
Dbpath=/data/mongodb/data
Logpath=/data/mongodb/log/mongod.log
Fork=true
#auth =true #添加管理员后取消注释, restart the authentication mode, do not comment, start adding-noauth

#bin目录, copy all files from the unpacking bin directory to the bin of the installation directory

./mongod–f/data/mongodb/conf/mongod.conf

#参数

-F configuration file

....

#登录

Mongo

Use admin

#创建管理员账户

Db.createuser ({User: "root", pwd: "Root", Roles:[{role: "Useradminanydatabase", DB: "Admin"}]})

#查看账户

> Show Users;
{
"_id": "Admin.root",
"User": "Root",
"DB": "admin",
"Roles": [
{
"Role": "Useradminanydatabase",
"DB": "admin"
}
]
}

> Db.system.users.find ()
{"_id": "Admin.root", "User": "Root", "db": "admin", "credentials": {"Scram-sha-1": {"IterationCount": 10000, "SA LT ":" 1tgn5bepbecuwxrna91t7g== "," Storedkey ":" s8abuikxg21ehmmnbhbh+jujld4= "," Serverkey ":" Rlrv3suuodtoqv3p0df5fuwnpnq= "}}," Roles ": [{" Role ":" Useradminanydatabase "," db ":" Admin "}]}

#验证

Db.auth ("root", "root")

#db名

>db

Admin

> Db.getname ()
Admin

MongoDB (i)

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.