so using the mongodb shell, I was able to create a database and add a username and password to it. How can I do the same in php? I have everything installed and able to connect to mongodb server.
However, I can’t find any information in the doc.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I do not believe
addUser()is implemented in the PHP driver.However, there is an
executethat should allow you to do anaddUser()the same way you would from the mongo shell:EDIT: After testing, I couldn’t get
executeto do what you wanted, but I did find that the following works:That adds a new user to the admin db on my server – checked via mongo shell after executing PHP script.
That said – why do you want to add a Mongo user from a PHP script?