Created
October 29, 2012 12:46
-
-
Save naxhh/3973328 to your computer and use it in GitHub Desktop.
Useful mongo-shell-admin commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Login admin | |
> use admin | |
> db.auth('user','pass') | |
#Basic shows | |
> show dbs | |
> show collections | |
> db.collection.getIndexes() | |
#Create Index | |
> db.collection.ensureIndex({ field:1, field2:-1 }) | |
#Delete Index | |
> db.collection.dropIndex("index_name") (or fields in object) | |
#Import data | |
mongoimport --db <db> -c <coll> < <file.json> | |
#If you exported a entireDB (/folder/*.bson) use: | |
mongorestore -d <db>--directoryperdb </path/folder> | |
#Export data | |
Mongo doesn't have a limit for export... a query needs to be done. | |
mongoexport --db <db> -c <col> -o <file> [-q <query> (--jsonArray / --csv) ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment