This article mainly introduces the PHP under the remote database to connect to the code, the need for friends can refer to the following
WINDOWS Under-Loaded MongoDB
Go to the official website first download: Https://www.mongodb.com/download-center#atlas
1. Create the data, logs folder, and mongo.conf in the MongoDB folder
Command-line command!
d:\mongodb\bin> mongod--dbpath D:\mongodb\data--logpath=d:\mongodb\logs\mongodb.log--logappend D:\mongodb \bin> Mongod-dbpath "d:\mongodb\data\db" d:\mongodb\bin> mongod--config "d:\mongodb\mongo.conf"
2, Configuration mongo.conf
Dbpath=d:\program files\mongodb\server\3.2\data #数据库路径 Logpath=d:\program Files\mongodb\server\3.2\logs\mongo.log # Log output file path logappend=true #错误日志采用追加模式 journal=true #启用日志文件, quiet=true #这个选项可以过滤掉一些无用的日志信息 enabled by default, set to False if debugging is required port= 27017 #端口号 defaults to 27017
3, the MONGO set as a service, easy to start later
Mongod--config "D:\Program files\mongodb\server\3.2\mongo.conf"--install--servicename "MongoDB" net start MongoDB
PHP connection
$conn = new Mongoclient ("Mongodb://xxx", Array (' username ' = ' username ', ' Password ' = ' password '); $db = $conn->test; $collection = $db->test; $cursor = $collection->find (); foreach ($cursor as $id = + $value) {echo "$id:"; Var_dump ($value); echo "<br>"; }