Turn on MongoDB database password verification

Source: Internet
Author: User


Install Moogodb can refer to my previous blog

http://blog.51cto.com/1767340368/2092546


1. Log in to the database

[Email protected] bin]# pwd

/opt/mongodb/bin[[email protected] bin]# ./mongo> use adminswitched to db admin> db.createuser ({User: "root", pwd: " 123456 ", roles:[" root "]}) #创建数据库管理员账号密码Successfully added User: {" user ":" Root "," roles ": [" root "]}> Exitbye

2. Restart the MongoDB service

[[Email protected] ~]# service MongoDB restart


3. Login again, no password authentication is not able to execute the command


4. Password verification

> Db.auth (' Root ', ' 123456 ') 1> #返回1代表成功


5. Test the command again (success)

> Show DBS


# #附加也可以通过这种方式进行验证, same effect

[Email protected] bin]#/mongo admin-u root-p123456




Turn on MongoDB database password verification

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.