After installation, enter in the console:
MONGO start the client.
Show DBS displays all databases.
Use XXX to select the database for the current database.
Show collections displays all collections of the current database.
Db.colleciton.find () to find all the data for the table.
Db.serverstatus () View the status of the database server.
Db.stats () queries the statistics for the specified database.
Use XXX Create a database if the database does not exist (you must insert a piece of data in it)
Db.storeCollection.insert ({' Version ': ' ', ' segment ': ' 456 '}) inserts the data and creates the collection
Db.dropdatabase () Delete database
Db.mycoll.drop () Delete collection
Db.storeCollection.save ({' Version ': ' 3.5 ', ' segment ': ' E3OL6 '}) Update record
Db.storeCollection.remove ({' Version ': ' 3.5 '}) Delete record
Db.page.ensureIndex ({' title ': 1, ' URL ':-1} ') create INDEX, 1 positive sequence, -1 reverse order
Db.page.getIndexes () The index established by the query
Db.mycoll.dropIndex (name) deletes the index and deletes all indexes without parameters
Db.baseSe.reIndex () Rebuild Index
Db.baseSe.storageSize () queries the available storage space for a collection of specified databases
Db.baseSe.totalSize () query collection allocated storage space
PS: Failed to start problem after abnormal shutdown
a period of time accidentally shut down the MongoDB, ready to reboot but found no, the error message is as follows:
Tue Apr 11:13:30 Tue Apr 11:13:30 warning:32-bit servers don ' t have journaling enabled by default.
Please use the--journal if you want durability. Tue Apr 11:13:30 Tue Apr 11:13:30 [Initandlisten] MongoDB starting:pid=7128-port=27017 dbpath=d:\programs\mongodb2 04\db 32-bit host=falcon Tue Apr 11:13:30 [initandlisten] Tue Apr 11:13:30 [initandlisten] * * Note:when using Mongo DB bit, are limited to about 2 gigabytes of data Tue APR 11:13:30 [Initandlisten] * * * http://blog.mongodb. org/post/137788967/32-bit-limitations Tue Apr 11:13:30 [Initandlisten] * * with--journal, the limit is lower Tue Apr 11:13:30 [Initandlisten] Tue Apr 11:13:30 [initandlisten] db version v2.0.4, pdfile version 4.5 Tue APR 17 11:13:30 [Initandlisten] git version:329f3c47fe8136c03392c8f0e548506cb21f8ebf Tue Apr 11:13:30 [Initandlisten] Build Info:win Dows Sys.getwindowsversion (major=6, minor=0, build=6002, platform=2, service_pack= ' Service Pack 2 ') boost_lib_version=1_42 Tue APR 11:13:30 [Initandlisten] Options: {dbpath: "D:\Programs\mongodb204\db"} ************** unclean shutdown
Detected.
Please visit Http://dochub.mongodb.org/core/repair for recovery instructions. Tue Apr 11:13:30 [Initandlisten] exception in initandlisten:12596 old lock file, terminating Tue APR 17
11:13:30 dbexit:tue APR 11:13:30 [Initandlisten] shutdown:going to close listening sockets ...
Tue APR 11:13:30 [Initandlisten] shutdown:going to flush diaglog ...
Tue APR 11:13:30 [Initandlisten] shutdown:going to close sockets ...
Tue APR 11:13:30 [Initandlisten] shutdown:waiting for FS preallocator ...
Tue APR 11:13:30 [Initandlisten] shutdown:closing All Files ...
Tue APR 11:13:30 [Initandlisten] Closeallfiles () finished Tue Apr 11:13:30 dbexit:really exiting now
Workaround:
1, delete%mongo_home%/db under the. lock file
2, input command Mongod--repair
3, restart MongoDB