title: How to use mongorestore/mongodump with username and password?
body: <p>I know this is a basic security measure, but I can't make it works with my mongodb installation. Each time I run the command :</p>
  
  <pre><code>mongorestore dump_folder -u "username" -p "password"
  </code></pre>
  
  <p>It returns:</p>
  
  <pre><code>error reading database: not authorized on DATABASE_NAME to execute command { listCollections: 1, cursor: { batchSize: 0 } }
  </code></pre>
  
  <p>My question is : What is the permission that I need to enable and how ?</p>
  
  <p>For the time being, I just turn off the Mongo's security in <code>/etc/mongod.conf</code> and start it back after I restore/dump my databases. </p>
  
  <p>Additional Note:
  This is how I prepared my databases and its user</p>
  
  <ol>
  <li>I log in with my admin account, create a database, named DATABASE001</li>
  <li><p>And create a user:</p>
  
  <pre><code>use DATABASE001
  db.createUser({ 
    user: "USER001", 
    pwd: "mypassword",
    roles:[ { role: "readWrite", db: "DATABASE001" },"dbAdmin"  ]
  })
  </code></pre></li>
  </ol>
  
  <p>For roles, I add <code>readWrite</code> to DATABASE001 and also <code>dbAdmin</code>
  I want this user (USER001) be able to backup or restore his database (DATABASE001). </p>
  
  <ol start="3">
  <li><p>I tested it by login with this command. It successfully logged in</p>
  
  <pre><code>mongo localhost -u USER001 -p mypassword --authenticationDatabase DATABASE001
  </code></pre></li>
  <li><p>I want to dump this database content with:</p>
  
  <pre><code>mongodump  -u USER001 -p mypassword --authenticationDatabase DATABASE001
  </code></pre>
  
  <p>it throws me an error: 
  <code>Failed: error getting database names: not authorized on admin to execute command { listDatabases: 1 }</code></p></li>
  </ol>
  
  <p>What is this <code>listDatabases</code> ? how can I add it to my roles?</p>