Super Admin
For more secure access to MongoDB, visitors are required to provide a user name and password, so users need to be created in MongoDB
Using the role-user-database security management method
Common system roles are as follows:
Root: Only available in the Admin database, super account, super privilege
READ: Allows the user to read the specified database
ReadWrite: Allows the user to read and write to the specified database
Create a Super Admin user
Use admindb.createuser ({ User:'admin', pwd:' 123', roles:[{role:'root', DB:' Admin'}]})
The Ubuntu Environment
Modify /etc/mongodb.conf
, setauth=true
sudo vim/etc/mongodb.conf
/etc/mongodb.conf
There is a configuration in the file auth=true
, just delete the previous "#".
Restart MongoDB
Service MongoDB Stop # Stop MongoDB Service (because MongoDB is self-booting with boot)# Open MongoDB service
You are prompted that an unauthorized administrator executes the command, and obviously the security verification check is turned on successfully, and you mongo admin -u root -p 123456
should connect this way:
Or you can also verify this (provided that the user must enter the corresponding database, the 1 represents success):
Under the WinDOS environment
- After creating the administrator:
- Then restart
mongodb
, but you must add the --auth
option to modify the contents of the. bat file to:mongod --auth --dbpath D:\软件安装\MongoDB\data\db
MongoDB Identity Verification