Difference between revisions of "MongoDB"

From wikieduonline
Jump to navigation Jump to search
Tags: Mobile web edit, Mobile edit
Tags: Mobile web edit, Mobile edit
Line 12: Line 12:
 
* Backup database to binary JSON ([[BSON]]) files (<code>--out</code>): <code>mongodump --host mongodb1.example.net --port 37017 --username user --password "pass" --out /opt/backup/mongodump-2011-10-24</code>
 
* Backup database to binary JSON ([[BSON]]) files (<code>--out</code>): <code>mongodump --host mongodb1.example.net --port 37017 --username user --password "pass" --out /opt/backup/mongodump-2011-10-24</code>
 
* <code>mongod --smallfiles --oplogSize 128 --replSet rs0 --storageEngine=mmapv1</code>
 
* <code>mongod --smallfiles --oplogSize 128 --replSet rs0 --storageEngine=mmapv1</code>
* db.myCollection.find()
+
* db.myCollection.find() or db.myCollection.find().pretty()
  
 
== See also ==
 
== See also ==

Revision as of 14:22, 15 February 2020

MongoDB is an open-source document-oriented database using a JSON-like documents with schema. Listen by default on port 27017.

  • Installation: brew tap mongodb/brew && brew install [email protected]
  • Runnig manually: mongod --config /usr/local/etc/mongod.conf --fork


Commands

  • Connect to mongoDB: mongo
  • List database: show databases
  • Connect to a database: use <your_db_name>
  • Backup your_db_name database to a file (--archive): mongodump --archive=test.20150715.archive --db your_db_name
  • Backup database to binary JSON (BSON) files (--out): mongodump --host mongodb1.example.net --port 37017 --username user --password "pass" --out /opt/backup/mongodump-2011-10-24
  • mongod --smallfiles --oplogSize 128 --replSet rs0 --storageEngine=mmapv1
  • db.myCollection.find() or db.myCollection.find().pretty()

See also

Advertising: