In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
1. Add user
MongoDB shell version: 1.8.2
Connecting to: 127.0.0.1:30000/test
>
>
>
> use admin
Switched to db admin
> db.addUser ('admin','admin')
{
"user": "admin"
"readOnly": false
"pwd": "7c67ef13bbd4cae106d959320af3f704"
}
>
two。 Restart with the-- auth parameter
MONGODB_HOME/bin/mongod-- fork-- logpath=$MONGODB_HOME/logs/mongodb.log-- dbpath=$DATA_PATH-- port=$MONGODB_PORT-- auth
3. test
MongoDB shell version: 1.8.2
Connecting to: 127.0.0.1:30000/test
>
> use admin
Switched to db admin
> show collections
Sat Aug 6 11:16:45 uncaught exception: error: {
"$err": "unauthorized db:admin lock type:-1 client:127.0.0.1"
"code": 10057
}
Switched to db admin
> db.auth ('admin','admin')
one
> show collections
System.indexes
System.users
> an error will be reported before executing db.auth ('admin','admin'), saying that it is unauthorized
4. Java client calls also need to use a user name and password, simply add a sentence
Db.authenticate ("admin", "admin" .toCharArray ())
5. The user added under admin is a super administrator and can access any database. With a super administrator, a user can be added to a single database, and this user can only access his database.
> use test
Switched to db test
> db.addUser ("test", "test")
{
"user": "test"
"readOnly": false
"pwd": "a6de521abefc2fed4f5876855a3484f5"
} 6. It can still be executed without authorization.
Db.shutdownServer () stops the node
Therefore, the server port running mongodb must strictly authorize access.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.