note 117348 added to mongo.connecting.auth
| From: | dan at kayakaddict dot co dot uk | Date: | Mon, 25 May 2015 16:18:35 +0000 |
| Subject: | note 117348 added to mongo.connecting.auth | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-202665@lists.php.net to get a copy of this message | ||
For connecting to a replica set with authentication it is possible to use a connection string like
the following (substitute the port numbers, replica set name and DB with your own)
$m = new
MongoClient("mongodb://${username}:${password}@localhost:27037,mongodb://${username}:${password}@localhost:27038",
array("replicaSet" => "test"_replica, "db" =>
"mytestdb"));
The second member string "mongodb://${username}:${password}@localhost:27038" does not need
the username and password - however, if the connection to the first member fails I have not tested
to see if the username and password persist to the second member.
----
Server IP: 72.52.91.14
Probable Submitter: 188.221.11.193
----
Manual Page -- http://php.net/manual/en/mongo.connecting.auth.php
Edit -- https://master.php.net/note/edit/117348
Del: integrated -- https://master.php.net/note/delete/117348/integrated
Del: useless -- https://master.php.net/note/delete/117348/useless
Del: bad code -- https://master.php.net/note/delete/117348/bad+code
Del: spam -- https://master.php.net/note/delete/117348/spam
Del: non-english -- https://master.php.net/note/delete/117348/non-english
Del: in docs -- https://master.php.net/note/delete/117348/in+docs
Del: other reasons-- https://master.php.net/note/delete/117348
Reject -- https://master.php.net/note/reject/117348
Search -- https://master.php.net/manage/user-notes.php