命令行输入mongo进入数据库操作
use demo创建或切换到数据库名为demo的数据库
代码演示
E:\MongoDB\bin>mongo
MongoDB shell version: 2.6.5
connecting to: test
> use demodb
switched to db demodb
> db.FirstCollection.insert({name:"jack",age:22})
WriteResult({ "nInserted" : 1 })
> show collections //显示数据库的表
FirstCollection
system.indexes
> db.getCollectionNames()
[ "FirstCollection", "system.indexes" ]
> db.demodb.find()
> db.FirstCollection.find()
{ "_id" : ObjectId("543731431dc491f307663a0d"), "name" : "jack", "age" : 22 }
> db.system.indexes.find()
{ "v" : 1, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "demodb.FirstCollection" }
登录数据库 db.auth('gary','111111')
进入表查看 db.tablename.find()