PHP extensions to MongoDB (first known as before) _javascript tips

Source: Internet
Author: User
Tags install mongodb log log mongodb mongodb server win32 web database
In the blogger's bullying for everyone to do a little sharing, hereby affirms that Bo Master product very simple is a bully, absolutely no inducements.
Due to the mongodb of the relevant Chinese information is less, then if there is a chance to continue to share. Hope this small share can bring you a harvest, please look down.

Why do you say "first knowledge", because the MONGODB data storage format is a result of the MongoDB document structure is Bjson format (bjson full name: Binaryjson), and the Bjson format itself to support the preservation of binary format data, Therefore, the data in binary format of the file can be saved directly into the MongoDB document structure.

MongoDB consists of (database), collection (collection), document objects (documents) three levels.
Correspondence with relational databases:

MongoDB Database of relational database

Database Database
Table Collection

Row Document
In MongoDB, the index can be indexed, and collection has a default hidden field _id, the field.

Installation use

Install MongoDB and simply use the MongoDB command under Windows
First, download, Extract files
To the official download of the appropriate version http://www.mongodb.org/downloads
For example: Http://fastdl.mongodb.org/win32/mongodb-win32-i386-2.2.1.zip
After decompression, put it under the corresponding letter, for example: D:\mongodb
second, the installation
1. Add the bin directory to the environment variable D:\mongodb\bin
2. Create a Data folder under the D:\mongodb to put it, and also create a DB folder under the data file, no DB folder MongoDB not start properly
3. Simple Start MongoDB method:
Go to the Bin directory
Copy Code code as follows:

C:\Documents and Settings\me>d:
D:\>CD Mongodb/bin
D:\mongodb\bin>mongod–dbpath D:/mongodb/data
D:\mongodb\bin>mongod–dbpath D:/mongodb/data

Displays the following:
Sun 14:56:03 MongoDB starting:pid=860 port=27017 dbpath=d:/mongodb/d
ATA 32-bit

* * Note:when using MongoDB bit, are limited to about 2 gigabytes of data

* * Http://blog.mongodb.org/post/137788967/32-bit-limitations

Sun 14:56:03 db version v2.2.1, pdfile version 4.5
Sun 14:56:03 git version:0eb017e9b2828155a67c5612183337b89e12e291
Sun 14:56:03 sys info:windows (5, 1, 2600, 2, ' Service Pack 3′) boost_li
B_version=1_35
Sun 14:56:03 [Initandlisten] waiting for connections on port 27017
Sun 14:56:03 [WEBSVR] Web admin interface listening on port 28017

Note:You must first create the data folder and execute to the bin directory. The default connection port for the MongoDB server is 27017

2. Add to registry as Windows service startup, start Windows as MySQL automatically starts the service and executes in the bin directory
Copy Code code as follows:

D:\mongodb\bin>mongod--logpath D:\mongodb\log\log1.log--logappend
--dbpath D:\mongodb\data--directoryperdb--servicename mongodb–install

After the completion of the output below (360 etc anti-virus software will be blocked, need to allow through)
All output Going To:d:\mongodb\logs\log1.log
Creating Service MongoDB
Service creation successful.
Service can is started from the command line via ' net start ' Mongodb″ '.

D:\mongodb\bin>

Where: The Log\log1.log log is output in an append way, –servicename MongoDB is the service name
Start Mongodb:net start MongoDB
Stop Mongodb:net Stop MongoDB
Note: After adding to the registry restart the computer in the service item can see that has been started, but the service is still not started, restart service found to 360 security guards to prevent the need to be determined again to start.

3.mongodb Simple Use command, to the bin command to execute Mongo.exe into the admin interface, the default is to enter the test account.
Copy Code code as follows:

D:\mongodb\bin>mongo.exe
MongoDB Shell version:2.2.1
Connecting To:test
> Show DBS;
Admin
Local

> Help; View command prompt


third, the next, is the same as all database operations to add a user's ability to ask
But what if the user who created it doesn't have permission to view the collection? In fact, I have a headache for everyone, so can insist on the intention to see the students here will not have a headache.
Execute the following command on the Mongo.exe admin interface that you just entered

Copy Code code as follows:

>use Admin
>db.auth ("sa", "sa")
>use Web
>show Collections

It's going to be a smooth time.

Iv. MongoDB Creating a database can be used as follows: use web; this creates a database
Switch to the Web database, and if not, create one automatically after inserting the data, and you will see a new Web folder in the information directory
Copy Code code as follows:

> Use web;

Switched to DB web
> Db.my.save ({a:10}); Save a message to collection my and if not, collection automatically creates a
> Db.my.find (); Retrieving All records
{"_id": ObjectId ("4d32c9204e6100000000691e"), "a": 10}
> Show Collections;
My
System.indexes
>exit; exit

The installation and user rights settings for MongoDB have ended.
Here are a few graphic language management tools
1. Use the graphical language management tool "Mongovue 0.9.7.2"


After entering, you can see


2. A more recommended management software is "Rockmongo"
PHP needs to run the environment to support, I prefer it, because the PHP programmer has a ready-made environment do not need white, hehe.
(1). Download a Rockmongo, unzip and put it in the Web directory download address: http://rockmongo.com/downloads
If you don't have PHP running environment, but want to use Rockmongo, you can download the package in the download address.
(2). Download a PHP support for MongoDB php_mongo.dll download address: https://github.com/mongodb/mongo-php-driver/downloads
(3). Add this line of code to the php.ini extension=php_mongo.dll and then restart Apache to view Php_info


Indicates that the installation was successful
(4). Enter the address of Rockmongo in the browser, the login box appears, login is OK. The default user is: admin password: admin
There are a lot of other tools that you can explore slowly.

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.