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

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

解决:

  1. 启动:
/home/appuser/data/mongodb/bin/mongod --port 27017 --fork --logpath /home/appuser/data/mongodb/logs/mongod.log --dbpath /home/appuser/data/mongodb/db
  1. 查看MongoDB版本
$ ./mongo --version
MongoDB shell version: 3.2.7
  1. 进入mongo,查看认证
$ ./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. 修改authSchema的currentVersion版本为 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服务,重新添加用户即可。
posted @ 2019-05-29 15:16  Philly008  阅读(19590)  评论(0编辑  收藏  举报