Win7 Installing MongoDB extensions

Source: Internet
Author: User
Tags install mongodb

1. install MongoDB.

Download Mongodb-win32-i386-2.0.0.zip file (address: Http://downloads.mongodb.org/win32/mongodb-win32-i386-2.0.0.zip),

Unzip it into the D:\xampp\mongodb directory. Create a D:\xampp\mongodb\data directory (for storing database files).

Because I use XAMPP, so I want to choose this directory, easy to manage, you can choose the directory.

Note: The bin directory has the following 2 files, Mongod.exe is the server side, Mongo.exe client (used in PHP to connect MongoDB it to query)

2. Running MongoDB

Go to the following installation of MongoDB: D:\mangodb\bin\ execution below

Mongod.exe--dbpath d:\mongodb\data can.

3. Installing PHP Extensions

First select the computer's extension in Http://pecl.php.net/package/mongo/1.6.14/windows

The extracted php_mongo.dll files are then copied to the Ext directory under the PHP installation directory. Extension = Php_mongo.dll is added to PHP.ini, and MONGO information can be found in phpinfo after restarting Apache.

<?php
$conn = new Mongo ("mongodb://127.0.0.1:27017");
$db = $conn->test; Select Test Database
$collection = $db->phptest; If this table does not exist, it will be created by itself
$collection->insert (Array (' name ' = ' aaa ', ' age ' = ' 21 '));
$collection->insert (Array (' name ' = ' bbb ', ' age ' = ' 20 '));
$collection->insert (Array (' name ' = ' CCC ', ' age ' = ' 25 '));

$array =array ();
foreach ($collection->find () as $val) {
$array []= $val;
}
Echo ' <pre> ';
Print_r ($array);
?>

Print

Win7 Installing MongoDB extensions

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.