Unable to show dbs

Posted December 20, 2017 13.6k views
MongoDBUbuntu 16.04


I followed this tutorial to setup mongodb , all seems working correctly. However when i put following commands :

> show dbs 
2017-12-20T21:40:26.799+0000 E QUERY    [thread1] Error: listDatabases failed:{
    "ok" : 0,
    "errmsg" : "not authorized on admin to execute command { listDatabases: 1.0 }",
    "code" : 13,
    "codeName" : "Unauthorized"
} :

Someone could say me why?

Thank you

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

It looks like you’ve enable user authentication for MongoDB. In fact, that’s the exact error you would expect to receive following Step 3 of the tutorial — Verifying that Unauthenticated Users are Restricted.

If you’ve created users and passwords for Mongo, you will need to connect to it like so:

  • mongo -u userName -p --authenticationDatabase admin

See the MongoDB documentation to learn more about user authentication.

by Melissa Anderson
MongoDB is a document-oriented database that is free and open-source. It is classified as a NoSQL database because it does not rely on a traditional table-based relational database structure ... In Part One of this tutorial we'll use the MongoDB Repository to install the latest version of MongoDB. In Part Two, we'll enable authentication to secure it on the local system. Finally, in Part Three, we'll show how to more securely allow remote connections if they're needed.