./bin/mongo --host xupan003 --port 27017use bikedb.auth('xp','xp')show tables--createCollectiondb.createCollection("bike")db.createCollection("user")db.createCollection("logs")db.dropDatabase("bike")--insertdb.logs.insert({"name":"xp","age":"25"})db.logs.insert({"name":"jay","age":"38"})db.logs.insert({"name":"jolin","age":"36"})db.logs.insert({"name":"jj","age":"25"})--finddb.logs.find()db.logs.find({"name":"xp"})db.logs.find({"name":"xp","age":"25"})db.logs.find({"name":"xp","age":"25"})--update 更新多条数据db.logs.update({"age":"25"},{$set:{"age":"18"}},{multi:true})更新第一个满足的数据db.logs.update({"age":"18"},{$set:{"age":"25"}})--删除db.logs.remove({"name":"jolin"})db.logs.insert({"name":"jj","age":"24"})--删除第一条满足的数据db.logs.remove({"name":"jj"},1)--查看索引db.logs.getIndexs()--添加索引. 1:升序db.logs.ensureIndex({"name":1})--删除索引db.logs.dropIndex({"name":1})/usr/local/devtools/mongdb/mongodb3.4drwxr-xr-x 2 root root 4096 Dec 15 10:54 bindrwxr-xr-x 4 root root 4096 Dec 19 13:03 db-rw-r--r-- 1 1046 1046 34520 Aug 24 2015 GNU-AGPL-3.0drwxr-xr-x 2 root root 4096 Dec 15 10:58 logs-rw-r--r-- 1 root root 223 Dec 15 14:20 mongodb.conf-rw-r--r-- 1 root root 5 Dec 15 11:35 mongo.pid-rw-r--r-- 1 1046 1046 1359 Aug 24 2015 README-rwxr-xr-x 1 root root 160 Dec 15 14:59 startMongoService.sh-rwxrwxrwx 1 root root 70 Dec 15 14:24 stopMongoService.sh-rw-r--r-- 1 1046 1046 22660 Aug 24 2015 THIRD-PARTY-NOTICESstartbin/mongod --port 27017 --auth --fork -dbpath=/usr/local/devtools/mongdb/mongodb/db/ --logpath=/usr/local/devtools/mongdb/mongodb/logs/mongodb.log --logappend