Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases

Access Control for MongoDB

I am getting a warning about Access Control as in my command prompt below.

I have:

  • successfully started the mongodb daemon (by running C:\path\to\mongodb\bin\mongod.exe) and I have

  • connected to MongoDB from a different Command prompt window (by running run C:\pathToMongodb\bin\mongo.exe)

Please see below output from my command prompt. Any ideas about what to do to solve it and why?

C:\Program Files\MongoDB\Server\3.4\bin>mongo.exe MongoDB shell version v3.4.0 connecting to: mongodb://127.0.0.1:27017 MongoDB server version: 3.4.0 Welcome to the MongoDB shell. For interactive help, type "help". For more comprehensive documentation, see http://docs.mongodb.org/ Questions? Try the support group http://groups.google.com/group/mongodb-user Server has startup warnings: 2016-12-04T21:13:44.410+1000 I CONTROL [initandlisten] 2016-12-04T21:13:44.410+1000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database. 2016-12-04T21:13:44.411+1000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted. 2016-12-04T21:13:44.413+1000 I CONTROL [initandlisten]

1 Answer

These are the standard warning messages if you have not set up any authentication and authorization (security controls) for MongoDB. It basically means that when you connect to MongoDB that you can access any database and collection on the system (and this would be the same for anyone accessing your instance of MongoDB. However, since it's likely just running on your PC, you may not need a secured environment. You can set up authentication and authorization yourself if you wish. The following documentation will help you set up authentication/authorization in MongoDB.

https://docs.mongodb.com/v3.2/tutorial/enable-authentication/ https://docs.mongodb.com/v3.2/core/authorization/

You can also stop the warning messages by adding a startup parameter in your MongoDB configuration file. The parameter is:

security: authorization: disabled

https://docs.mongodb.com/v3.2/reference/configuration-options/#security.authorization