Can't create backup mongodump with --db. Authentication failed

后端 未结 14 1008
深忆病人
深忆病人 2020-12-29 18:22

When I create backup of all databases in MongoDB (version 3):

mongodump --username bacUser --password 12345

It\'s OK. But when I try to cre

14条回答
  •  我在风中等你
    2020-12-29 18:30

    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:

    1. Remove your old local mongo (be careful, it may remove all your local database)
    sudo apt remove mongo-clients mongodb
    
    1. Import the public key used by the package management system.
    sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv D68FA50FEA312927
    
    1. Create a list file for MongoDB.

      • Ubuntu 14.04
    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
    
    • Ubuntu 16.04
    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
    
    1. 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 : -d  -u  -p  -o 
    

提交回复
热议问题