mongoDB test error - mongodb

I came to know about mongoDB and looked for test.So I made it install and then for test when I used command mongo on terminal it showed an error like this
MongoDB shell version: 1.8.2
connecting to: test
Sun Jul 31 01:06:07 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:79
exception: connect failed
So can someone tell me what is the problem.I am using ubuntu 11.04.For installation instruction I had used this site.I am newbie to this mongoDB so please helpe me.Any help will be highly appreciable.

All you need to do is open 2 terminal tabs. In one, run
mongod
which starts the MongoDB server.
In the other, run
mongo
which is the shell that connects to your MongoDB server.

It looks like MongoDB isn't running. Can you connect to the web interface in your browser?
http://localhost:28017
Also, do you see the process running on your machine? You should see an entry for mongod when running ...
$ top
or
$ ps aux

why not install mongodb from 10gen's own debian repository? much easier and more likely to work
http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages
To see if mongodb is running, this also helps:
sudo service mongodb status
if it is running, and you still get the same error, then it must be the weird localhost bug that mongodb has. it assumes localhost is 127.0.1.1 for some reason. try
mongo 127.0.1.1

I had the same problem. Just try to create folder c:\data and next c:\data\db

Related

Mongodb is not running

I have installed mongodb in my computer. But whenever I try to launch it, it's not running. I have entered command , as "mongo" to start the mongodb, which shows following resuts, but the application is not opening.
Any one having any idea how can I fix this? Please share it. Thanx!
Environment: Ubuntu 16.04
Those are warnings that appear at the first mongo start. Don't worry to much about them.
Since the process is still running and you got the small > character there, that means you successfully connected to the MongoDB server.
mongod is the MongoDB server (you can check if it's running by running ps aux | grep mongod) and the mongo cli tool is a cli client connecting to the server. Here you can run commands.
For example, create your first document:
use myDatabase
db.people.insert({ name: "Rhea" })
db.people.find()
In conclusion, both the MongoDB server and client are running but you got a few warnings that only appear the first time when you run mongo.
Initially in one terminal write mongod.
Then on another terminal : mongo .
The first one will start the mongo server.
The second one will start the interpreter.
You can try various commands in the interpreter.

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.

How to start mongdb in Linux mint?

I would like to ask on how to start mongodb in linux mint. I tried sudo service mongod start but it shows the error mongod: unrecognized service. Why is this happen. When I run the sudo service in ubuntu Linux there is no problem like this. BUt why its not work in Linux mint? Is there a solution for this?
I just installed Mongo DB in LinuxMint Sarah (18) and for me, the following command worked:
sudo service mongodb start.
Checking that it works can be done either by executing 'top' command or checking the log file in mongodb folder (instructions in the following link ---> https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/#run-mongodb-community-edition)
For stopping mongodb, the same command but typing stop 'sudo service mongodb stop'
In the previous link, both commands are included but without the 'b', maybe they just made a typing mistake :)

Issue with installation of Mongo DB on Windows 8.1

I am trying to install Mongo DB on a windows 8.1 64 bit machine and I a getting the following error.
C:\MongoDB\bin>mongo.exe
MongoDB shell version: 2.4.7
connecting to: test
Tue Nov 19 14:50:02.652 Error: couldn't connect to server 127.0.0.1:27017 at src
/mongo/shell/mongo.js:145
exception: connect failed
Make sure you have the daemon process running. You start it via mongod.exe. You are running the client side and by default connecting to port 27017 - the default mongo instance. Check your running processes for mongod first!
Make sure to unclick the download compass section when you download the shell. As soon as I unclicked it I was able to install the Mongodb shell. Hope this helps - I was stuck with this problem for a long time.

mongo db testing error

I came to know about Mongo db. So I installed it on ubuntu 11.04. To check whether it is installed or not I checked it in software center and it was there. So for test I made command in terminal as
$mongo
but it is something like this
Error: couldn't connect to server 127.0.0.1 shell/mongo.js:79.
so can someone tell me how to solve this problem.
Your mongod is not running. Check the process list using "ps" and restart the mongod service if it is not started.