basic mongodb

basic mongodb

basic mongodb

Components

mongod

mongod is the primary daemon process for the MongoDB system. It handles data requests, manages data format, and performs background management operations.

--dbpath <path> Specify a directory for the mongod instance to store its data. Typical locations include: /srv/mongodb, /var/lib/mongodb or /opt/mongodb

Unless specified, mongod will look for data files in the default /data/db directory. (Windows systems use the datadb direc‐ tory.) If you installed using a package management system. Check the /etc/mongodb.conf file provided by your packages to see the configuration of the dbpath.

--directoryperdb Alters the storage pattern of the data directory to store each database's files in a distinct folder. This option will create directories within the --dbpath named for each directory.

Use this option in conjunction with your file system and device configuration so that MongoDB will store data on a number of distinct disk devices to increase write throughput or disk capacity.

mongo

http://docs.mongodb.org/manual/tutorial/getting-started/

mongo

By default, mongo looks for a database server listening on port 27017 on the localhost interface. To connect to a server on a different port or interface, use the --port and --host options.

Select a database

db

show dbs

use mydb

Create a Collection and Insert Documents

j = { name : "mongo" }
k = { x : 3 }

db.testData.insert( j )
db.testData.insert( k )

show collections

db.testData.find()

Post by: Jalen Wang (转载请注明出处)

原文地址:https://www.cnblogs.com/jalenwang/p/3405548.html