Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-8367

php mongodb authentication

    • 2

      Details
      -----------------------------------------------------------------------------
      PHP Version 5.5.12
      Compiler MSVC11 (Visual C++ 2012)
      Architecture x64
      mongodb driver: php_mongo-1.5.7-5.5-vc11-x86_64.dll
      -----------------------------------------------------------------------------

      Please give example how to connect to mongodb

      I try this:
      $m = new MongoClient ("mongodb://$user:$pass@{$host}:{$port}");

      Or this:
      $m = new MongoClient ("mongodb://{$host}:{$port}",[
      'username' => $user,
      'password' => $pass
      ]);

      Error I have got:
      Failed to connect to: localhost:27017: SASL Authentication failed on database 'admin': Authentication failed.

            Assignee:
            allison.moore@mongodb.com Allison Reinheimer Moore
            Reporter:
            dnkumk@gmail.com Dnku Mekonen
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:
              7 years, 25 weeks, 2 days ago