2

NOTE: I have tried not setting bind_ip and also setting it to 0.0.0.0 -- neither one fixed my issue.

This is my mongod.conf file:

systemLog:
    destination: file
    path: "/root/mongodb.log"
    logAppend: true

net:
    port: 25015

processManagement:
    fork: true

setParameter:
    enableLocalhostAuthBypass: true

storage:
    dbPath: /root/mongo_data
    engine: wiredTiger
  1. The first thing I did was SSH in to the DigitalOcean droplet where it is running and do the following:

    mongo --port 25019
    

I was able to connect, so I know it picked up the options in the mongod.conf file.

  1. The second thing I did was issue the following command:

    > use admin;
    switched to db admin
    > db.createUser(
        {
            user: "siteUserAdmin",
            pwd: "eqt-dfts-mad-ghbr-ovd-g",
            roles: [{role: "userAdminAnyDatabase", db: "admin"}]
        }
    )
    Successfully added user: {
        "user" : "siteUserAdmin",
        "roles" : [
            {
                "role" : "userAdminAnyDatabase",
                "db" : "admin"
            }
        ]
    }
    

So that was apparently a success!

  1. Next I exited from the mongo shell and then logged in to the mongo shell again as siteUserAdmin with credential from above.

  2. Then I created a user and a database for the app I'm building:

    > use MyDatabase;
    switched to db MyDatabase
    > db.createUser(
        {
            user: "my_user",
            pwd: "cu-npp-re-jpor-mtw-e-s",
            roles: [
                {role: "readWrite", db: "MyDatabase"},
                {role: "dbAdmin", db: "MyDatabase"}
            ]
        }
        )
    Successfully added user: {
        "user" : "vantage",
        "roles" : [
            {
                "role" : "readWrite",
                "db" : "AdVantage"
            },
            {
                "role" : "dbAdmin",
                "db" : "AdVantage"
            }
        ]
    }
    

So that was also apparently a success!

  1. I then exited the mongo shell and then logged in to the mongo shell again as my_user with credentials from (4). I confirmed that I was able to create a collection called demotest in MyDatabase:

    > use MyDatabase;
    switched to db MyDatabse
    > db.createCollection("demotest")
    { "ok" : 1 }
    > show collections;
    demotest
    > show dbs;
    MyDatabase 0.000GB
    admin      0.000GB
    local      0.000GB
    > exit
    bye
    

So far so good.

  1. I then switched to a terminal on my local machine. My goal is to be able to connect to this MongoDB instance from my local machine and from an app that is running somewhere else on the internet. So I issued the following command on my local machine:

    PROMPT> mongo --host 102.216.73.164 -u my_user -p cu-npp-re-jpor-mtw-e-s --authenticationDatabase MyDatabase --port 25019
    MongoDB shell version: 2.6.6
    connecting to: 102.216.73.164:25019/test
    2015-05-13T21:03:18.963-0400 Error: 18 { ok: 0.0, errmsg: "auth failed", code: 18 } at src/mongo/shell/db.js:1210
    exception: login failed
    

Here is what I don't understand:

  1. why did it try to connect to the test database?

  2. why doesn't it work?

4
  • 3
    The local machine says 'MongoDB shell version: 2.6.6`. I think their were some changes to authentication in the upgrade to 3.0. So I think you either need MongoDB 3.0 shell on local machine or to fiddle with the authorisation scheme of the server.
    – user728291
    May 14, 2015 at 9:15
  • thanks, @user728291 - if you make this an aswer, I'll mark it as correct.
    – tadasajon
    May 14, 2015 at 15:37
  • @JonCrowell, did this work? How did this square with your local 2.6.6 install of Mongo shell? Are you using Mongo 3.0 on your local dev box with Meteor?
    – Aaron
    May 14, 2015 at 17:00
  • @Aaron Yes, I was having connection issues, but it was because I had not upgraded Mongo shell and my pymongo driver to be compatible with 3.0. Once I did that, I was over the hump.
    – tadasajon
    May 14, 2015 at 17:07

1 Answer 1

1

I've had the same authentication issue on an MMS deployed db (though it has nothing to do with it).

  1. it tries to connect to /test by default. If you want another database, just specify it, e.g. 102.216.73.164/foo.

  2. upgrade your mongo shell to 3.0.3 (you currently use 2.6.6). That solved the problem for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.