Skip to content

Latest commit

 

History

History
56 lines (41 loc) · 752 Bytes

File metadata and controls

56 lines (41 loc) · 752 Bytes

MongoDB

Create DB

use db;

Create User

use db;
db.createUser({
  "user": "user",
  "pwd": "password",
  "roles": ["readWrite", "dbOwner", "dbAdmin"]
})

Crete Collection

db.createCollection("collectionName", )

Backup & Restore

mon

Install brew

brew tap mongodb/brew
brew install mongodb-database-tools

DUMP (EXPORT DOWNLOAD!) in ~/db/dbname/*

mongodump \
  --host ds34456436.mongolab.com \
  -d dbname \
  --port 876867 \
  --username user \
  --password pass \
  --collection user \
  --collection order \
  --out ~/db

RESTORE (IMPORT UPLOAD!) from ~/db/dbname/*

mongorestore --host localhost --port 21017 -d dbNewName ~/db/dbname