$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;');
或者
$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 命令连接
./mongo -host 192.168.1.188 -u test1 -ptest --authenticationDatabase Test
参考
http://cn2.php.net/manual/en/mongodb-driver-manager.construct.php
https://docs.mongodb.com/manual/reference/connection-string/#connections-connection-options
最后更新于 2020年5月17日
相关博文
php 连接mongodb方法