Mongorestore to mlab authentication failed


#1

Hi. This might be the wrong place to post this, but I’m just wondering if I’m making an obvious mistake because at the moment I’m kind of stuck…

I’m (finally) going to move my database from locally built in (MUP) to mlab. I have used mlab’s free tier as a test-database so I’m at least familiar with the layout they use (I’m a noob when it comes to databases and pretty much everything else, but I’m trying to learn).

Since I’ve never done this before I figured a test-run would be smart.

Now, what I did was ssh into my server (on DO). Then I took a mongodump by running

docker run --rm --link mongodb:mongo -v /root:/backup mongo \
 bash -c ‘mongodump --out /backup --host mongo:27017’.

I located the folder in which the backup was stored and it seems to have worked successfully. Then I logged in to mlab.com.

I created a new free tier database let’s call it “testdatabase” and then I created a database-user which we will call “testUser” with “testPassword” as password.

I went into the database then clicked on “tools” where there are some guidelines for importing database

mongorestore -h dsxxx.mlab.com:xxx -d testdatabase -u <user> -p <password> <input db directory>

So I put in:

mongorestore -h dsxxx.mlab.com:xxx -d testdatabase-u testUser -p testPassword backupDirectory/

This is the result:

connected to: dsxxx.mlab.com:xxx
assertion: 18 { ok: 0.0, errmsg: "auth failed", code: 18, codeName: "AuthenticationFailed" }

I read some places you needed to add a --authenticationDatabase admin, but this did not change anything.

Any help is appreciated.