Search code examples
mongodbmongodump

Mongodump doesn't work as expected


I am trying to host my database online and based on what I have found online, I need to use mongodump to export my database first.

The way to use mongodump if am not wrong is:

mongodump -d <db-name> -o <directory>

when I use the above command, I get the following error in the terminal:

Failed: error connecting to db server: no reachable servers

I tried to add --host=127.0.0.1 after mongodump as follows:

mongodump --host=127.0.0.1 -d <db-name> -o <directory>

But I still get the same result. What am I doing wrong here?

Update:

I managed to overcome the error by starting the MongoDB service with the following command:

brew services start mongodb

Now when I run mongodump, it seems to be working but I can't find it when I navigate to the directory where it supposed to be located!

NOTE: I am using Meteor technology, and I am accessing my database with meteor mongo command


Solution

  • You could try:

    Run mongodump --db <database> --port 3001 from the directory you want the output files to be created (it will create a dump dir with the files)

    The port is 3001, as it seems meteor doesn't use Mongodb default port

    Also, if nothing appears, try running with the -v flag for verbose mode, this will help you to find out why your files are not being created. Also, be sure yout database name is correct.