MongoDB Default user authentication is off.
Modify the/etc/mongod.conf file. MongoDB by default, any client can connect to port 27017 without authentication, which by default does not have an administrator account. By modifying this profile, you can change the permission authentication to login.
MongoDB If you want to create a user for a database, you need to enter the database first, and then use the AddUser command. Here you can also set the user to read-only (Db.adduser ("Jack", "Jack", true), and the third parameter indicates whether to "read-only user" at the time).
To use a super administrator, you need to connect to the Admin database and log in to the Administrator account, and then connect to other databases to exercise administrator privileges.
User Information preservation and certification process
Similar to MySQL, the system user information is saved in the Mysql.user table. MongoDB also stores the username and pwd of the system user in the Admin.system.users collection. where PWD = MD5 (username + ": MONGO:" + Real_password). There is nothing wrong with this in itself. Username and: MONGO: equivalent to adding a salt value to the original password, even if the attacker obtains the stored MD5 hash in the database, it is impossible to easily isolate the original password from the Rainbow table.
Rights Management Common commands
1. #进入数据库admin
Use admin
2. #增加或修改用户密码
Db.adduser (' name ', ' pwd ')
3. #查看用户列表
Db.system.users.find ()
4. #用户认证
Db.auth (' name ', ' pwd ')
This one returns 1 certification successful, only the successful authentication to the database operation
5. #删除用户
Db.removeuser (' name ')
6. #查看所有用户
Show Users
7. #查看所有数据库
Show DBS
8. #查看所有的collection
Show collections
9. #查看各collection的状态
Db.printcollectionstats ()
Ten. #查看主从复制状态
Db.printreplicationinfo ()
How to create a database with a user name and password for MongoDB