1、首先要启动mongodb
set MANGO_HOME=C:\Database\MongoDB\Server\3.0 Set PATH=%MANGO_HOME%\bin;%PATH% mongod --dbpath=D:\Database\MongoDB3\db
2、然后启动mongo命令行
set MANGO_HOME=C:\Program Files\MongoDB\Server\3.0 Set PATH=%MANGO_HOME%\bin;%PATH% mongo
3、列出并选用db
show dbs use test show collections
4、插入数据,新建collection
db.person.insert({"name":"neo","age":"26","sex":"male"}) db.person.insert({"name":"joe","age":"28","sex":"male"})
5、查询
db.person.find() db.person.find({"name":"joe"})
6、更新
db.person.update({"name":"joe"},{"name":"joe","age":"29","sex":"male"}) db.person.update({"name":"joe"},{$set:{"age":"28"}})
6、删除
db.person.remove({"name":"joe"}) db.person.remove({})