26

I have started the M101 MongoDB online course. I am simply following this video to the point at 1:45 minutes into the video.

The restoremongo call returns mongorestore: command not found. This should connect to the server(which I can connect to and is running on my machine).

This is where I am at; please see below. I have copied and pasted the server info beneath this.
Any solutions?

tar xvf hw1-1.957cdceb1c1e.tar 
x dump/
x dump/m101/
x dump/m101/funnynumbers.bson
x dump/m101/funnynumbers.metadata.json
x dump/m101/hw1.bson
x dump/m101/hw1.metadata.json
Geralds-MacBook-Pro:Downloads geraldnolan$ mongorestore
-bash: mongorestore: command not found

Server:

bsondump    mongodump   mongoimport mongorestore    mongostat
mongo       mongoexport mongooplog  mongos      mongotop
mongod      mongofiles  mongoperf   mongosniff
Geralds-MacBook-Pro:bin geraldnolan$ ./mongod
./mongod --help for help and startup options
Tue Jun 11 10:30:06.413 [initandlisten] MongoDB starting : pid=15803 port=27017 dbpath=/data/db/ 64-bit host=Geralds-MacBook-Pro.local
Tue Jun 11 10:30:06.414 [initandlisten] 
Tue Jun 11 10:30:06.414 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
Tue Jun 11 10:30:06.414 [initandlisten] db version v2.4.4
Tue Jun 11 10:30:06.414 [initandlisten] git version: 4ec1fb96702c9d4c57b1e06dd34eb73a16e407d2
Tue Jun 11 10:30:06.414 [initandlisten] build info: Darwin bs-osx-106-x86-64-2.10gen.cc 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
Tue Jun 11 10:30:06.414 [initandlisten] allocator: system
Tue Jun 11 10:30:06.414 [initandlisten] options: {}
Tue Jun 11 10:30:06.415 [initandlisten] journal dir=/data/db/journal
Tue Jun 11 10:30:06.415 [initandlisten] recover : no journal files present, no recovery needed
Tue Jun 11 10:30:06.461 [websvr] admin web console waiting for connections on port 28017
Tue Jun 11 10:30:06.461 [initandlisten] waiting for connections on port 27017
Adinia
  • 3,722
  • 5
  • 40
  • 58
user2472438
  • 269
  • 1
  • 3
  • 3
  • Where do you call this command from? Are you sure that you have $MONGO_HOME/bin in your path? If not - you have to call the command directly from the */bin directory. – user Jun 11 '13 at 09:58

11 Answers11

17

if you installed mongo using Macports, you need to also install mongo-tools to get mongodump, mongorestore, etc

Black
  • 5,023
  • 6
  • 63
  • 92
7

It seems your PATH is not set for the mongodb.

Goto the directory where you "bin" directory is.

In bin directory you will find the mongorestore command.

In the same terminal where your dump directory is, type:

export PATH = $PATH: "the complete path to your bin directory for Mongo"

After doing this execute > mongorestore dump and it should run.

See this https://discussions.apple.com/thread/1012390?start=0&tstart=0

Talha Awan
  • 4,573
  • 4
  • 25
  • 40
shank
  • 143
  • 2
  • 13
7

if your'e on a mac, simply use brew to install mongo

brew install mongo
eladHayun
  • 223
  • 4
  • 11
3

I too faced this issue while trying to configure mongodb in my windows machine. Sharing the procedure that I followed to fix the same, so that this could be helpful for someone later.

What is the issue?

Windows machine not recognizing MongoDB Tools in command line interface.

What is the solution?

In order for the CLI to recoganize the MongoDB Tools commands, you have to add the MongoDB Tools bin path to your system environment variables. Ref

The path will be normally.

C:\Program Files\MongoDB\Tools\100\bin

Please note: This is the bin folder of MongoDB Tools and not the bin folder for MongoDB Server.

In order to make the CLI aware regarding the MongoDB Tools commands like mongo, mongod, 'mongos' etc we add the server bin path to environment variable, that will be usually C:\Program Files\MongoDB\Server\4.4\bin, this is the location where those exe files are present. (Check the folder location in your local machine).

Similarly in order to make the CLI aware regarding MongoDB Tools commands like mongodump, mongoexport, mongoimport, we need to add the bin folder path of MongoDB tools to environment variable, that will be usually C:\Program Files\MongoDB\Tools\100\bin, this is the location where those exe files are present. (Check the folder location in your local machine).

By adding the evvironment variables, you are making the system aware of the path where the defenition for the commands are written.

Nitheesh
  • 19,238
  • 3
  • 22
  • 49
2
mongorestore --db databasename backuplink(E:\zims)

Before download https://www.mongodb.com/try/download/database-tools and paste mongorestore tools.exe into your mongobin folder

Tomer Shetah
  • 8,413
  • 7
  • 27
  • 35
  • Please try to elaborate what is this tool, and how it should help solve the problem. – Tomer Shetah Dec 17 '20 at 09:49
  • In mongo server 5.0, the mongorestore tool (amongst others) isnot in the bin folder by default anymore, so you have to download them. – Asoub Mar 18 '22 at 17:06
1

This works on Windows:

mongorestore "path/to/dump"

after

mongo
> use m101
> db.hw1.findOne()
kelvincer
  • 5,929
  • 6
  • 27
  • 32
0

Below is what worked for me:

<complete path of mongorestore in your local mongo folder> -h <host:port> <complete path where the dump folder is present>

For example:

~/Documents/basicsoft/mongodb-osx-x86_64-3.0.5/bin/mongorestore -h 0.0.0.0:27017 ~/Downloads/dump

1. That is, when you give mongorestore, it may not be able to find the mongorestore command which is present in the bin folder of your local download of mongoDB(I am guessing that you are trying this in your local mongo instance). Hence you need to provide the complete path of the mongorestore present in bin folder

  1. The second value is to specify that you are trying to perform this operation on your local server. Hence provide the local mongo server and port number after -h which indicates the host.

3. The third value should be the path to the folder which has the dump which should be restored to your mongodb.

Make sure you have your mongoDB up and running before you try this.

SHILPA AR
  • 332
  • 2
  • 7
  • 18
0

I solved this problem like this on my Mac: Go to bin directory of Mongo installation and type following command: ./mongorestore --path of your homework dump folder--

Note: make sure your mongod is running

Verify: type in show dbs and you should see m101

0

In my case, mongo was installed but the bin folder still didn't contain mongorestore or mongodump. When I looked more closely at the logs from installing mongo, there were a lot of successful logs, but also this error:

Error: The 'brew link' step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/mongo
Target /usr/local/bin/mongo
is a symlink belonging to mongodb-community-shell. You can unlink it:
  brew unlink mongodb-community-shell

I fixed it with:

$ brew unlink mongodb-community-shell

And then

$ brew link mongodb

Then I could use mongorestore and mongodump.

Bart S
  • 1,698
  • 1
  • 16
  • 21
0

My problem on windows was that some database tools were missing from my bin folder.

I solved this by downloading them from here and dropping them in my mongoDB bin folder (the one added to PATH).

0

i also face same issue may be it makes sense but i open the git bash in bin directory and type mongorestore it shows this error but at the same time i opened cmd from windows and redirect to bin directory and again type mongorestore it works fine