MongoDB认证错误com.mongodb.MongoCommandException: Command failed with error 18: 'auth failed',实际上已填写正确账号密码
solve:
- start up:
/home/appuser/data/mongodb/bin/mongod --port 27017 --fork --logpath /home/appuser/data/mongodb/logs/mongod.log --dbpath /home/appuser/data/mongodb/db
- View MongoDB version
$ ./mongo --version
MongoDB shell version: 3.2.7
- Enter mongo, View certification
$ ./mongo
MongoDB Enterprise > use admin
switched to db admin
MongoDB Enterprise > db.auth('admin', 'admin')
1
MongoDB Enterprise > db.system.version.find()
{ "_id" : "authSchema", "currentVersion" : 5 }
- Modify authSchema of currentVersion version 3
MongoDB Enterprise > var schema = db.system.version.findOne({"_id" : "authSchema"})
MongoDB Enterprise > schema.currentVersion = 3
3
MongoDB Enterprise > db.system.version.save(schema)
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
- MongoDB restart the service, users can re-add.