MongoDB入门操作

1.将下载的mongodb等可执行文件存放路径配置到环境path(配置整个文件夹)
2.创建数据库文件存放路劲,如d:\db
3.打开库,命令如下
打开一个cmd命令窗口,输入命令 mongod --dbpath=d:\db; 运行结果会看到一串日志,再开一个cmd命令窗口,输入mongo,连接默认数据库test
4.其他操作可以看help

> help
        db.help()                    help on db methods
        db.mycoll.help()             help on collection methods
        rs.help()                    help on replica set methods
        help admin                   administrative help
        help connect                 connecting to a db help
        help keys                    key shortcuts
        help misc                    misc things to know
        help mr                      mapreduce

        show dbs                     show database names
        show collections             show collections in current database
        show users                   show users in current database
        show profile                 show most recent system.profile entries wit
h time >= 1ms
        show logs                    show the accessible logger names
        show log [name]              prints out the last segment of log in memor
y, 'global' is default
        use <db_name>                set current database
        db.foo.find()                list objects in collection foo
        db.foo.find( { a : 1 } )     list objects in foo where a == 1
        it                           result of the last line evaluated; use to f
urther iterate
        DBQuery.shellBatchSize = x   set default number of items to display on s
hell
        exit                         quit the mongo shell
>

posted on 2012-11-15 15:49  cyz_393  阅读(66)  评论(0)    收藏  举报