Mongo Shell/Compass won't connect to mongodb container - mongodb

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.

Related

MongoDB not getting connected to EC2 server

mongo mongodb+srv://root:<password>#cluster0-5etkj.mongodb.net:27017/cretanium?retryWrites=true
MongoDB shell version: 2.6.10
connecting to: mongodb+srv://root:<password>#cluster0-5etkj.mongodb.net:27017/cretanium?retryWrites=true
2020-01-08T12:14:51.648+0000 Assertion failure _setName.size() src/mongo/client/dbclientinterface.h 231
2020-01-08T12:14:51.649+0000 0x6b75c9 0x659e9f 0x636a32 0x5013b8 0x4fa7f1 0x6006fd 0x5eb869 0x7f8128226d76 0x3340f1406362
mongo(_ZN5mongo15printStackTraceERSo+0x39) [0x6b75c9]
mongo(_ZN5mongo10logContextEPKc+0x21f) [0x659e9f]
mongo(_ZN5mongo12verifyFailedEPKcS1_j+0x142) [0x636a32]
mongo(_ZN5mongo16ConnectionStringC1ENS0_14ConnectionTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_+0x208) [0x5013b8]
mongo(_ZN5mongo16ConnectionString5parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERS6_+0x201) [0x4fa7f1]
mongo(_ZN5mongo17mongoConsExternalEPNS_7V8ScopeERKN2v89ArgumentsE+0x11d) [0x6006fd]
mongo(_ZN5mongo7V8Scope10v8CallbackERKN2v89ArgumentsE+0xa9) [0x5eb869]
/usr/lib/libv8.so.3.14.5(+0x99d76) [0x7f8128226d76]
[0x3340f1406362]
2020-01-08T12:14:51.650+0000 Error: assertion src/mongo/client/dbclientinterface.h:231 at src/mongo/shell/mongo.js:148
exception: connect failed
I am trying to connect to mongo atlas using command line on EC2 Server and it is getting connected on my local machine but I cannot connect it on EC2 Server. I'm able to ping to google.com, so external connectivity is not an issue but I'm unable to connect to mongodb from ec2 command line as well.
You're using mongo shell version 2.6.10. This version is not supported anymore.
This is an expected error when you're trying to connect to a newer server version (Atlas is currently using either 3.6, 4.0, or 4.2 as of this moment) using an old shell version (see SERVER-16610).
Please upgrade your local MongoDB installation to a newer one. See Install MongoDB for an instruction for your specific OS.

Mongo DB: 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.

Mongo: network error while attempting to run command 'whatsmyuri' on host

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.

error connecting to mongodb service on windows

I recently started the mongodb service on my windows machine, and it is running succesfully. Or at least I think it is, though I am not 100% sure and I don't know what port it is running on because all attempts to check the status have failed. When I try to run mongo.exe, I get the following error:
paul#PAUL_LAPTOP /c/program files/mongodb 2.6 standard/bin
$ mongo
MongoDB shell version: 2.6.3
connecting to: test
2014-08-11T03:36:15.802-0400 warning: Failed to connect to 127.0.0.1:27017, reas
on: errno:10061 No connection could be made because the target machine actively
refused it.
2014-08-11T03:36:15.808-0400 Error: couldn't connect to server 127.0.0.1:27017 (
127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146
exception: connect failed
Any ideas how I could check why this is happeing? One good first step would be checking the status of my mongo service, which I am not sure how to do.
Any help is greatly appreciated.
Thanks,
Paul
Have you gonbe through all the steps here: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/?
You need to run the mongod command to start mongodb, and you also have to define the path where mongodb shall store your database:
C:\mongodb\bin\mongod.exe --dbpath d:\test\mongodb\data
When you typed in the mongod command, did you also give it a path? This is the step beforehand and this is usually the issue.
mongod --dbpath="put your path to where you want it to save the working area for your database here!! without these silly quotations marks I may also add!"
example: mongod --dbpath=C:/Users/Kyle-3/Desktop/DEV/dangerzonearea/test/mongodb
That is my path and don't forget if on windows to flip the slashes forward if you copied it or it won't work!

Cannot Connect MongoDB from Meteor

I need to connect MongoDB from Meteor. I have installed MongoDB using the command prompt. After that, I have tried to connect to the MongoDB. This time I got an error.I didn't have any idea about this. Does anybody have suggestions as to what to do?
Error :
E:***\MongoDB\bin>mongo.exe
MongoDB shell version: 2.4.9
connecting to: test
Mon Jan 20 12:56:37.648 Error: couldn't connect to server *.*.*.*:27017 at src
/mongo/shell/mongo.js:145
exception: connect failed
There are different ways depending on how whether or not you've deployed it or not.
If you've run meteor deploy some.url.com, you can access your site from a new terminal window by inputting meteor mongo some.url.com.
If you're simply run meteor to get your app running (not deployed), open a new terminal, cd to the directory of your project, and enter meteor mongo.