title: Mongodump from secure Mongo database
body: <p>In order for me to connect to this [secure] Mongo instance I have to run the following command:</p>
  
  <p><code>mongo --ssl --host sampleHostname --sslPEMKeyFile /path/to/user.pem --sslCAFile /path/to/mongoca.cer --authenticationDatabase '$external' --authenticationMechanism=MONGODB-X509</code></p>
  
  <p>I am trying to do a <code>mongodump</code> command to get the data but I keep running into the following errors:</p>
  
  <p><strong>Attempt 1</strong></p>
  
  <p><code>mongodump -d mydb</code></p>
  
  <p><code>Failed: error connecting to db server: no reachable servers</code></p>
  
  <p><strong>Attempt 2</strong>
  <a href="https://stackoverflow.com/questions/31993168/cant-create-backup-mongodump-with-db-authentication-failed">Can&#39;t create backup mongodump with --db. Authentication failed</a></p>
  
  <p><code>mongodump -d mydb --authenticationDatabse '$external'</code></p>
  
  <p><code>Failed: error connecting to db server: no reachable servers</code></p>
  
  <p><strong>Attempt 3</strong> Using the same command as how I connect.</p>
  
  <p><code>mongodump -d mydb --ssl --host sampleHostname --sslPEMKeyFile /path/to/user.pem --sslCAFile /path/to/mongoca.cer --authenticationDatabase '$external' --authenticationMechanism=MONGODB-X509</code></p>
  
  <p><code>Failed: error getting collections for database 'mydb': error running 'listCollections'. Database: 'mydb' Err: not authorized on 'mydb' to execute command {listCollections: 1, cursor: {} }</code></p>
  
  <p>I have tried the same command with sudo but it still returns the same error. </p>
  
  <p><strong>Attempt 4</strong> <a href="https://stackoverflow.com/questions/20490291/minimum-permission-for-using-mongodump-to-dump-a-specific-db">Minimum permission for using mongodump (to dump a specific db)</a></p>
  
  <p><code>mongodump -d mydb --ssl --host sampleHostname --sslPEMKeyFile /path/to/user.pem --sslCAFile /path/to/mongoca.cer --authenticationDatabase '$external' --authenticationMechanism=MONGODB-X509 --excludeCollection=system.indexes</code></p>
  
  <p><code>Failed: error getting collections for database 'mydb': error running 'listCollections'. Database: 'mydb' Err: not authorized on 'mydb' to execute command {listCollections: 1, cursor: {} }</code></p>
  
  <p>I am stuck and I am eventually going to run <code>mongorestore</code> but I do not want to run this without making sure I am able to backup first. I imagine the solution for <code>mongodump</code> will resolve any possible issues I may have with <code>mongorestore</code> (if any).</p>