Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mongodb enables authentication

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. Add administrative user admin

# mongo

> use admin

> db.addUser ('admin','123456')

2. Enable authentication

# cat / etc/mongodb.conf

Fork = true

Bind_ip = 192.168.1.10

Port = 27017

Quiet = true

Dbpath = / data/mongodb

Logpath = / tmp/mongod.log

Logappend = true

Journal = true

Auth=true # enable authentication

3. Restart the mongod process

# mongo 192.168.1.10

MongoDB shell version: 2.4.3

Connecting to: 192.168.1.10/test

>

>

> use admin

Switched to db admin

>

> show collections

Mon May 6 17:18:36.971 JavaScript execution failed: error: {

"$err": "not authorized for query on admin.system.namespaces"

"code": 16550

} at src/mongo/shell/query.js:L128

>

> db.auth ('admin','123456')

one

>

> show collections

System.indexes

System.users

>

> show dbs

Admin 0.203125GB

Local 0.078125GB

Monitor_log 0.203125GB

Test 0.203125GB

>

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report