In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Access Control of MongoDB Learning arrangement
1. To restrict access to a specific IP address, you only need to add-- bind_ip parameter when starting, and-- host when the client connects.
/ app/mongo/mongodb/bin/mongod-dbpath=/app/mongo/mongodb/data/test-logpath=/app/mongo/mongodb/data/test/server.log-fork-bind_ip 132.42.33.190
/ app/mongo/mongodb/bin/mongo-- host 132.42.33.190
2. To set the port, you only need to add-- port parameter when starting, and-- port when the client connects.
/ app/mongo/mongodb/bin/mongod-dbpath=/app/mongo/mongodb/data/test-logpath=/app/mongo/mongodb/data/test/server.log-fork-port 28018
/ app/mongo/mongodb/bin/mongo-- port 28012
3. User authentication management
Mongodb has an admin database by default, and the users on the admin library have greater permissions than other libraries, that is, users of the admin library can operate any operation of other libraries.
Enable: login verification
/ app/mongo/mongodb/bin/mongod-dbpath=/app/mongo/mongodb/data/test-logpath=/app/mongo/mongodb/data/test/server.log-fork-auth
Note: mongodb has an admin database by default. If there is no data in admin.system.users, login verification will not take effect.
1) create a user
> db.addUser ("root", "111111")-- New user
Db.auth ("root", "111111")-- set the user to have database connection verification
2) establish a user with specified permissions
Command format: db.addUser (username,password [, readOnly=false])
For example: add a read-only user user_reader to the test library, as shown in the code:
Db.addUser ("user_reader", "passw0rd", true)-- create a read-only user
> show collections-- you can check
System.indexes
System.users
> db.t1.insert ({name: "liangzhangping", age:29})-- but cannot be added, deleted or updated
Unauthorized
3) delete the specified user, call the db.removeUser (username) command, and simply pass in the user name to delete it. You can call db.system.users.find () to check whether to delete it.
> db.removeUser ("user_reader")
> db.system.users.find ()
{"_ id": ObjectId ("4fd9c4bc869208ca70bcf180"), "user": "test", "readOnly": false, "pwd": "ab29e5e0e27099729856ff91da2b9112"}
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.