Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MongoDB cannot login, always Authentication failed #11

Closed
ardinusawan opened this issue Jan 20, 2017 · 10 comments
Closed

MongoDB cannot login, always Authentication failed #11

ardinusawan opened this issue Jan 20, 2017 · 10 comments

Comments

@ardinusawan
Copy link
Contributor

MongoDB username and password are correct. I am using mlab.com.
If src in momyfile.json is my localhost, this code run without problem.
But, if src is another ip address (in this case i use mlab.com), I got message error

(node:4177) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): MongoError: Authentication failed.

Maybe in this code auth using MONGODB-CR, not SCRAM-SHA-1?

Regards

@cognitom
Copy link
Owner

cognitom commented Jan 21, 2017

Hi @ardinusawan, momy just calls MongoClient. connect() method.
https://github.com/cognitom/momy/blob/v0.7.0/lib/tailer.js#L178

See also this document:
http://mongodb.github.io/node-mongodb-native/2.2/api/MongoClient.html#.connect

It seems that the library only supports GSSAPI or MONGODB-CR at this point.
https://github.com/mongodb/node-mongodb-native/blob/2.2/lib/url_parser.js#L307

@cognitom
Copy link
Owner

@ardinusawan
Copy link
Contributor Author

So the solution is
mongodb.connect(this.url2?authMechanism=SCRAM-SHA-1&authSource=admin&maxPoolSize=5).then(db => { ......

Right?

@cognitom
Copy link
Owner

Looks close. You can write that in your momyfile.json. I haven't tried but It could be like this:

{
  "src": "mongodb://somewhere:27017/dbname?authMechanism=SCRAM-SHA-1"
}

@ardinusawan
Copy link
Contributor Author

Still cannot connect :(

@cognitom
Copy link
Owner

@ardinusawan momy needs replica set cluster. Don't you use database in Single-node sandbox?
If you don't have the right to access oplog, it would fail.
http://docs.mlab.com/oplog/#connecting-to-the-oplog

@ardinusawan
Copy link
Contributor Author

ardinusawan commented Jan 21, 2017

Yes im using Single-node sandbox.
So, now im move to digitalocean droplet.
I try to run script in droplet, src as localhost.
But when I run
momy --config momyfile.json --import

There is another error message ( not error auth message again :D )

(node:4378) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'ts' of null

What wrong?

@cognitom
Copy link
Owner

Hmm, it seems that momy couldn't get the information of ts (timestamp) from MySQL table. Could you check that mongo_to_mysql table was automatically created?
https://github.com/cognitom/momy#mysql

If not, your account might not have the privileges to create tables on MySQL.

@ardinusawan
Copy link
Contributor Author

ardinusawan commented Jan 21, 2017

Yeah @cognitom , mongo_to_mysql was automatically created :-/

@ardinusawan
Copy link
Contributor Author

Finally it work. Thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants