MongoDB authentication error com.mongodb.MongoCommandException: Command failed with error 18: 'auth failed', actually fill in the correct account password

MongoDB认证错误com.mongodb.MongoCommandException: Command failed with error 18: 'auth failed',实际上已填写正确账号密码

solve:

  1. 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
  1. View MongoDB version
$ ./mongo --version
MongoDB shell version: 3.2.7
  1. 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 }
  1. 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 }) 
  1. MongoDB restart the service, users can re-add.

Guess you like

Origin www.cnblogs.com/liuliu3/p/10944010.html
Recommended