If you are using mLab then it could be the version in your local mongo is not match with mLab. By default, Ubuntu will install mongo v2.x
and mLab is v3.x
. You could check with this command:
mongo --version
Install new mongo version:
- Remove your old local mongo (be careful, it may remove all your local database)
sudo apt remove mongo-clients mongodb
- Import the public key used by the package management system.
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv D68FA50FEA312927
Create a list file for MongoDB.
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
- Install the MongoDB packages
sudo apt-get install -y mongodb-org
Ref: https://docs.mongodb.com/v3.2/tutorial/install-mongodb-on-ubuntu/
Now you can dump your database with this command:
mongodump -h <host>:<port> -d <database-name> -u <user> -p <password> -o <output directory>