At the time of the test, the db.dropallusers () operation was performed under the Amin Library, and then all the administrator users did not have any action to prompt error:not authorized on admin to execute command ...
Here's how to handle this situation
First look at the configuration file for the current MONGO instance:
cat/etc/mongo.cnf systemLog:destination:file logappend:true path:/data/mongodata/log/mongo.log Logrota Te:rename timestampformat:ctime quiet:true storage:dbpath:/data/mongodata/data journal:enabled:true Commi tintervalms:100 directoryperdb:true syncperiodsecs:60 Engine:wiredtiger WiredTiger:engineConfig:cacheSiz Egb:20 journalcompressor:snappy indexConfig:prefixCompression:trueprocessManagement:fork:true Pidfile Path:/data/mongodata/data/mongo.pidnet:port:27017 bindip:0.0.0.0 maxincomingconnections:3000 Wireobjectcheck:tru E ipv6:false unixDomainSocket:enabled:false security:keyfile:/data/mongodata/data/keyfile author ization:enabledoperationprofiling:slowopthresholdms:100 Mode:slowop
Try 1: Change config file (failed)
After the search on the Internet to start Mongod service does not specify the--auth parameters can be, looked at the Mongod service startup script is to Mongod-f/etc/ Mongo.cnf way to start, I think is not the configuration file certification related to the configuration is prohibited, so the authorization:enabled to authorization:disabled, and then restart Mongod services, Discover or need certification
Try 2: Specify the parameters to start the service (success)
Change the configuration file can only specify the parameters to start the Mongod service, when the direct execution of Mongod--port 27017--dbpath/data/mongodata/data times wrong:
Detected data files In/data/mongodata/data created by the ' Wiredtiger ' storage engine, so setting the active storage Engi Ne to ' wiredtiger '.
Then according to the configuration file plus storage engine for Wiredtiger parameters, start again mongod--port 27017--dbpath/data/mongodata/data--storageengine Wiredtiger--WIREDTIGERCACHESIZEGB--wiredtigerjournalcompressor Snappy, found that there are errors:
Exception in initandlisten:72 requested option conflicts with current storage engine option for DIRECTORYPERDB; You requested False if the current server storage are already set to true and cannot be changed, terminating,
According to the error prompt plus Directoryperdb parameters start: Mongod--port 27017--dbpath/data/mongodata/data--storageengine Wiredtiger-- WIREDTIGERCACHESIZEGB--wiredtigerjournalcompressor Snappy--wiredtigerindexprefixcompression 1--directoryperdb, Finally, the root user can now be authorized in the Amdin library with a successful reboot.
Tips:
1, specifically to take which parameters to adjust according to the configuration file, if the specified parameters and instances of the original parameters of the conflict will not come, but it does not matter, MongoDB will have detailed log output, according to the prompt adjustment can
2, if the Mongod service startup script is not started with the root user, it is best to cut to the corresponding account to start, or after the authorization is finished again with the script will be reported permission denied error
!! Note: Db.dropallusers () is a high-risk operation and must not be performed in a production environment
MongoDB executes db.dropallusers () below the admin library, causing no administrative permissions to be handled