Can't authenticate on mongodb with PHP
问题 What i've done: Enabled authentication in /etc/mongod.conf : auth = true Created the first user from the shell as stated in the doc : db.createUser( { user: "admin", pwd: "admin", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] }) Using the admin user, i've created a root user to access mongodb: db.createUser( { user: "root", pwd: "root", roles: [ "root" ] }) Until this point all works fine, as i can authenticate from the mongo shell with: mongo --port 27017 -u root -p root admin and