How PHP connects to MongoDB

How PHP connects to MongoDB

$manager = new MongoDB\Driver\Manager('mongodb://test1:test1@192.168.1.188:27017,192.168.1.187:27017/AppStore?replicaSet=test&safe=true&w=1&wtimeoutMS=300000&authSource=AppStore&ssl=false;');

Or:

$options => array("replicaSet" => "test","safe"=>true,"w"=>1,"wtimeoutMS"=>2000,"authSource"=>"AppStore");
$dsn = 'mongodb://test1:test1@192.168.1.188:27017,192.168.1.187:27017';
$mongo =new MongoDB\Driver\Manager($dsn,  $options);

Linux command connection:

mongo -host 192.168.1.188 -u test1 -ptest --authenticationDatabase Test

Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *