I followed the instructions here for setting up users...
Then from another machine I do:
mongo -u admin -p adminpassword host/collection
The response I get is:
MongoDB shell version: 2.6.10 connecting to: host/collection
2019-07-12T06:20:36.336+0000 Error: 2 { ok: 0.0, errmsg: "Auth
mechanism not specified", code: 2, codeName: "BadValue" } at
src/mongo/shell/db.js:1287 exception: login failed
Now, I suppose this is an issue with different versions but what I'm really after is to remote connect from a node script and that's failing as well but the only message is: "MongoError: Authentication failed."
Does anyone know a solution?
Ran into the same issue when using an old Mongo shell version (2.x/3.x) with a 4.0+ server. Upgrading the Mongo shell to 4.0.6+ seems to have resolved the issue.
My guess is the protocol to authenticate and specifying auth mechanisms has changed in newer server versions.
Maybe is because you've tried to connect with admin user on a different collection than admin.
Try mongo -u ADMIN_USERNAME -p ADMIN_PASSWORD HOST_IP/admin
Related
I'm using Docker (running on WSL) and I have a MongoDB container running. Using mongo shell on my host I can connect to the instance, but I can't authenticate. I also get an authentication error when I try to go through MongoDB Compass, below is the error I keep getting. I've installed saslprep globally via npm on my host machine, but that didn't fix the problem either. Any help would be greatly appreciated!
> db.auth('admin-root', 'test')
Warning: no saslprep library specified. Passwords will not be sanitized
MongoError: Authentication failed.
I have 2 problems. First I can't login into my MongoDB. I tried this way: Can't create backup mongodump with --db. Authentication failed but no succsess. I've tried differnt passwords and user, but I can't log in. My Mongo Server runs on an Debian 8 Server. For Uninstall and install, I used this tutorial: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-debian/ . I start the debian new after every uninstall.
Can I remove the password. In the conf data, I comment auth = true. I hope you can help me.
I get this message
MongoDB shell version: 3.2.7
connecting to: 127.0.0.1:27017/test
2016-06-29T12:30:01.079+0000 E QUERY [thread1] Error: Authentication failed. :
DB.prototype._authOrThrow#src/mongo/shell/db.js:1441:20
#(auth):6:1
#(auth):1:2
exception: login failed
No authentication by default on mongo that might have to do with system privileges.
I try deploy my app Node.js + MongoDB.
I deployed my app on Heroku. Added add-ons Mongolab to app.
Opened my data base and create new user name: dima; password: *** (Add database user).
Then I try to connect to the DB:
My console:
mongo ds039135.mongolab.com:39135/heroku_xkbthxdx -u dima -p ***
MongoDB shell version: 2.4.9
connecting to: ds039135.mongolab.com:39135/heroku_xkbthxdx
Fri Feb 19 19:26:50.181 Error: 18 { ok: 0.0, errmsg: "auth failed", code: 18 } at src/mongo/shell/db.js:228
exception: login failed
What is missing in this? Thanks!
Your mongo shell version is 2.4.9. Currently all MongoLab Sandbox databases are version 3.
Upgrade your mongo shell to 3.x.y - preferably matching major release versions between client and server, MongoDB can be sensitive to major version discrepancies. Eg: Use 3.0.x shell with 3.0.x server, 2.6.x shell with 2.6.x server, etc.
Edit - adding the "why": Starting with 3.0, the default authentication mechanism is SCRAM-SHA-1, which the 2.4 mongo shell does not support, hence the failed authentication.
And then, if you have any problem with your user/pass, you can get your database username and password with:
heroku config | grep MONGODB_URI
The response is in the form of:
MONGOLAB_URI: mongodb://username:password#mlab.com:12345/db
I have been trying to access my mongo instance from another machine, but I get this error. I could not find many references to this whatsmyuri error. This is what I get from the external machine:
$ mongo <IP_ADDRESS>:27017/youtube_advertising -u user -p password
MongoDB shell version: 3.2.0
connecting to: <IP_ADDRESS>:27017/youtube_advertising
2016-02-19T17:10:02.923+0100 E QUERY [thread1] Error: network error while attempting to run command 'whatsmyuri' on host '<IP_ADDRESS>:27017' :
connect#src/mongo/shell/mongo.js:226:14
#(connect):1:6
exception: connect failed
I have already changed the /etc/mongod.conf file, opened connections through port 27017 (with iptables) and restarted mongo. I am able to connect via ssh to that machine.
Searching about this whatsmyuri, I ran this command on mongo:
> db.runCommand( { whatsmyuri: 1 } )
{ "you" : "127.0.0.1:36990", "ok" : 1 }
I do not know if that 36990 port is right or wrong. Just in case I opened connections from there too, but still nothing.
Any ideas?
UPDATE
Checking the /var/log/mongodb/mongod.log, this is what I get when I try to connect from remote:
2016-02-19T10:41:07.292-0600 I NETWORK [initandlisten] connection accepted from <EXT_IP_ADDRESS>:51800 #2 (1 connection now open)
2016-02-19T10:41:07.310-0600 I QUERY [conn2] operation isn't supported: 2010
2016-02-19T10:41:07.310-0600 I - [conn2] Assertion: 16141:cannot translate opcode 2010
Check your versions. That may help.
I was having the same problem. In my case, the server was version 3.2.0-rc2, while mongo shell version was 3.2.1.
Upgrading the server to 3.2.1 fixed the problem.
This issue bit me when I was running two versions (3.4 and 4.2) of MongoDB on the same Windows 10 machine. I ran v3.4 mongod with no problems mentioned in the console output, but then running the v3.4 mongo shell produced the above error. Checking the Task Manager, it turned out there was a MongoDB process (I'm not sure, but I think it was for v4.2) running. After ending that process through the Task Manager, the v3.4 mongo shell ran fine with no error.
Using mongodb-community-shell
In MacOs brew install mongodb/brew/mongodb-community-shell
It will ask you to overwrite link with mongo command.
brew link --overwrite mongodb-community-shell
The issue arises when the mongo client's and server's version mismatch.
Uninstall MongoDB from the client and for installation follow the detailed instruction provided over here.
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
The key step which needs to be done with the attention is
sudo apt-get install -y mongodb-org=4.2.7 mongodb-org-server=4.2.7 mongodb-org-shell=4.2.7 mongodb-org-mongos=4.2.7
mongodb-org-tools=4.2.7
Note: In my case, the mongo version of server was 4.2.7
Another thing that one can do is uninstall MongoDB from both the systems taking necessary backups and install it again.
I am hosting an app on heroku and I'm trying to connect it to the MongoDB database using the MongoLab addon. One of the steps is to type:
mongo ds044064-a0.mongolab.com:44064/heroku_w6fhwppg -u <dbuser> -p <dbpassword>
But I keep getting the error "mongo not found" Anyone have any ideas why? The add-on is installed.
Thanks!
mongo refers to the mongo shell binary, which you'll need to install locally. It, along with all the other MongoDB binaries, can be downloaded here:
https://www.mongodb.org/downloads