[SERVER-9991] MongoDB 2.4.3 fails to mongorestore test database Created: 21/Jun/13  Updated: 25/Oct/17  Resolved: 28/Jun/13

Status: Closed
Project: Core Server
Component/s: Security, Tools
Affects Version/s: None
Fix Version/s: None

Type: Question Priority: Major - P3
Reporter: Derek Crudgington Assignee: Andre de Frere
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

mongodb 2.4.3


Participants:

 Description   
  • On mongodb 2.4.3 a mongorestore fails to restore "test" database:

# mongorestore -uuser -ppass --host 127.0.0.1 -d test /var/backups/mongodb/.tmp/test
connected to: 127.0.0.1
assertion: 18 { code: 18, ok: 0.0, errmsg: "auth fails" }

# mongo --version
MongoDB shell version: 2.4.3

  • On mongodb 2.2.2 this works fine:

# mongorestore -uuser -ppass --host 127.0.0.1 -d test /var/backups/mongodb/.tmp/2013-06-21_18-15-51/test
connected to: 127.0.0.1
Fri Jun 21 18:16:14 /var/backups/mongodb/.tmp/2013-06-21_18-15-51/test/testData.bson
Fri Jun 21 18:16:14     going into namespace [test.testData]
Fri Jun 21 18:16:14 warning: Restoring to test.testData without dropping. Restored data will be inserted without raising errors; check your server log
2 objects found
Fri Jun 21 18:16:14     Creating index: { key: { _id: 1 }, ns: "test.testData", name: "_id_" }

# mongo --version
MongoDB shell version: 2.2.2

Did something change in the versions to not allow this anymore?



 Comments   
Comment by Khoa Nguyen [ 25/Oct/17 ]

Hi Everyone, I have the problem:
When connect to mongoDB version 2.4.14, enable auth = true
connect error: Error: 18

{ code: 18, ok: 0.0, errmsg: "auth fails" }

please me advance!
I try run cli: mongo --port 27017 -u myUserAdmin -p 'abc123' --authenticationDatabase 'admin'

Comment by Derek Crudgington [ 28/Jun/13 ]

Yes, and thank you! Can close this.

Comment by Andre de Frere [ 28/Jun/13 ]

Hi Derek,

My apologies, this ticket was closed prematurely.

The authenticationDatabase is a new option in 2.4.x release. There have been a number of changes and improvements to Authentication in MongoDB since 2.2.2, including the addition of roles for Security. In previous versions tools would attempt to authenticate against the admin database if they failed for the database they were being run against. This no longer happens by design.

Now the authenticationDatabase option needs to be passed if the user you are using does not have credentials in the database you are working against.

You can see more information on that in Documentation for mongorestore under 'authenticationDatabase'. The same is true of all tools since 2.4.

Given this, it appears that the database you are restoring to does not have the user credentials included. If this is the case, then the error you are receiving is the expected behaviour. Do you agree with this diagnosis?

Kind Regards,
André

Comment by Derek Crudgington [ 28/Jun/13 ]

Uh.. this is not resolved, but OK. You didn't even re produce it (didn't use the same command line options).

Comment by Derek Crudgington [ 28/Jun/13 ]

Hi,

I think the issue I'm hitting on 2.4.3 is I'm not using "--authenticationDatabase admin". When I specify that then it works.

Is this a new option? On 2.2.2 I don't have to specify it.

Comment by Andreas Nilsson [ 24/Jun/13 ]

I have have successfully performed mongodump/mongorestore on MongoDB 2.4.3 and 2.4.4 using the following commands:

./mongodump -udumper -ppass --authenticationDatabase admin -dtest
./mongorestore -udumper -ppass --authenticationDatabase admin -d test dump/test

The dumper account has the following roles in the admin database: ["readWriteAnyDatabase","userAdminAnyDatabase","dbAdminAnyDatabase"]

dacrud, can you double check that the username/password combination exists in the test database for the 2.4.3 instance. If it does can you provide the server logs of the failed authentication. Thanks.

Comment by Derek Crudgington [ 21/Jun/13 ]

If I take "auth = true" out of the mongodb.conf it still fails with the auth error on 2.4.3.

Generated at Thu Feb 08 03:21:59 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.