In Windows system, open mongodb username and password to log in

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~

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324421182&siteId=291194637