Turn on security verification
1) Run cmd with administrator privileges, enter the bin directory where you installed mongod and enter the following command to reinstall the MongoDB service
mongod --auth --logpath "g:\mongodb\logs\MongoDB.log" --logappend --dbpath "g:\mongodb\data" --directoryperdb --reinstall
2) Enter the command
net start mongodb
3) Open a second command line window (you can run it without an administrator)
Enter the command "mongo"
Enter show dbs again
At this time, an error will be reported
At this time, only the command can be entered
db.auth("XXXX","XXXXX")
If it returns immediately after input: Number 1, indicating successful login
At this time, enter show dbs again
You can view the secrets in your database~