First, the basic Environment configuration;
1, first to the official website (http://www.mongodb.org/downloads) Download the appropriate installation package, and then step by step next installation, of course, you can change the installation directory; After the installation is complete, configure the environment variables to find the Bin folder under the installation directory. In the computer environment variable, add its path (D:\MongoDB\bin, I installed in the D disk);
2, set up a directory for storing database files; Windows uses C:\data\db as the data directory by default. However, during the installation process, files or folders will not be created automatically, and you will need to create them yourself. Of course we can also create the file directory anywhere in the system, and then use the command--dbpath to set the data directory.
Mongod--dbpath Path
Create a new file directory in the D drive;
d:\>mkdir mongodbdatad:\>cd mongodbdatad:\mongodbdata>mkdir db
Of course, you can also set up without the command line;
3, use the command to specify the data storage directory;
Mongod--dbpath D:\MongoDBDATA\data
When you see this line "Waiting for connections on port 27017", enter http://localhost:27017/in the browser and you're done!
It looks like you is trying to access MongoDB over HTTP on the native driver port.
Second, the basic API additions and deletions to check;
1, CREATE database: Use[database];
Use test
2, view all databases;
> show dbslocal 0. 000GBtest 0.000GB
3, add a collection to the specified database and add records;
Db.persons.insert ({name: ' Jone '})
4. View all documents in the database;
Show collections
5, query the data of the specified document;
>"_id": ObjectId ("5714D7331BF2E414603681DF"), "name": "Jone"}
The FindOne () method can query the first one;
6, update the document data;
Db.persons.update ({name: ' Jone '},{$set: {name: "Eric"}})
7, delete the document data;
Db.persons.remove ({name: "Eric"})
MongoDB Note A--MONGODB basic environment configuration and additions and deletions to check;