I just started looking into MongoDB for some projects I’m working on. Reviewing the documentation I came across some PHP snippets that show how to connect and query and so on. One thing I’ve been having trouble finding is Authentication use case.
A lot of the information I’ve found the uses the connect method don’t have authentication methods when connecting to MongoDB.
Is Authentication required like it would be for MySQL on a local environment?
I’m using it right now with WAMP but I plan to move it to a LAMP web server when I’ve got the hang of how to use it properly.
I’m not sure how or when to use the authentication as I’m not sure if remote connections are restricted unless a user and password are created or if it’s just something I’ve not been able to find information on yet? I’ve done plenty of google and found nothing of use yet.
Advertisement
Answer
By default MongoDB does not use authentication!
In order to make it short: Unless you use MongoDB solely on your personal computer for training and education you should always enable authentication. There are MonogDB installations public in the Internet which are completely open.
The Mongo Documentation provides several tutorials: