MongoDB want to integrate PHP, need to install MONGO extension, this is relatively simple, now say MongoDB Phpapi and usageLet's look at a simple example:
PHP code
1.
2. $m = new Mongo (); This is the default connection to the local 27017 port,
MongoDB is a product between relational database and non relational database, and is the most powerful and relational database in the relational database.
The supported data structure is very loose and is a JSON-like Bjson format, so you can store
Common JavaScript statements
Copy Code code as follows:
Db.getsiblingdb ()
Db.getcollectionnames ()
Db.getcollection ()
Db.printcollectionstats ()
Running JavaScript scripts on the MONGO shell
To switch a database:
We know that MySQL in the installation of the need for us to set a database default username and password, MongoDB is no exception, but MongoDB is the default does not set access restrictions, do not need to enter a username and password can be
In the afternoon just set the password, forgot to save, the evening to eat a dinner back to forget. The study of a will find it is not difficult, but the internet did not search directly on the record, follow the following steps to operate
These days the project revision, the time is comparatively tight, the blog also did not keep abreast, also hoped everybody forgive me.
Well, today sharing the basic operation of the index in the MongoDB, we do not avoid the day-to-day development
1. Create a Super User
Use admin
db.createuser (
{
User: "Adminusername",
pwd: "UserPassword",
roles:
[
{
roles: "Useradminanydatabase",
DB: "admin"
}
)
There are two types of superuser
First run the Easy_install Pymongo command to install the Pymongo driver. Then do the action:Create a connection
Copy Code code as follows:
In [1]: Import Pymongo
In [2]: Connection = Pymongo. Connection (' localhost ', 27017)
Use Pymongo to connect to the MongoDB database in Python.The basic code is as follows: fromPymongoImportmongoclientclient= Mongoclient ('127.0.0.1', 27017)# the address of MongoDBDb_name ='Myfirstmongo' #the name of the databasedb =
1.MongoDB: Download the corresponding versionhttps://www.mongodb.org/=>download=>window=>download2. InstallationPress Default or select installation location step to head3. Create a Database Data storage folderLike d:/data/db.4. Start MongoDB
Continue the learning of MongoDB--Index specific explanation--Index management--Spatial Index1. Create a simple index(1) Prepare 200,000 data firstfor (var i = 0;iDb.books.insert ("number": I, "name": i+ "book")}(2) Check the query performancevar
1, the first step is to download from the official website to match their operating system installation files or compressed files;2, just find a folder to unpack the installation files, and then in the C packing directory to create a new folder
1. Create a new folder for storing database files. It is recommended to put it in the folder of your own username and it will be much easier without sudo.Under the user's own username environment: mkdir [folder name]2. Go to the MongoDB Bin
1. MongoDB is an open-source, document-oriented (not relational-oriented) non-SQL database that is written in C + + and is one of the most popular NoSQL databases today.2. MongoDB adds not structured data (table structure, pre-defined table
MongoDB Database Basic usage show DBS: Display Database list show collections: Displays a collection in the current database (similar to a table in a relational database) show users: Displays user use : Toggles the current database, It's the same
1, first example analysis of the following MongoDB aggregation operations:
This operation indicates that the count quantity under each group is counted according to the whoisserver_id field grouping:
Db.anhui.aggregate ({$group: {_id:'$
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