分享

在linux的命令行下如何直接执行Mongodb命令,就像db2一样?

haobinmarshal 发表于 2013-10-17 21:37:37 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 1 5884
在linux的shell命令行下如何能直接执行mongodb的命令,就像db2或mysql一样?
下说明一下,在linux的shell命令行下可以直接执行db2的查询命令,如:
db2 "select * from tab_name"
再如直接执行mysql的命令,如:
mysql -uroot -ppassword -e "use db;select * from tab_name;"
上面对db2和mysql的举例,都是不通过db2和mysql提供的客户端而执行的sql命令,mongodb能不能实现这样的操作?
              
               
               

已有(1)人评论

跳转到指定楼层
rucypli 发表于 2013-10-17 21:38:14

            [root@XXXXXXXXXXXXXXXX bin]# ./mongo
MongoDB shell version: 1.8.2-pre-
connecting to: test
> help
        db.help()                    help on db methods
        db.mycoll.help()             help on collection methods
        rs.help()                    help on replica set methods
        help connect                 connecting to a db help
        help admin                   administrative help
        help misc                    misc things to know
        help mr                      mapreduce help
        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 with time >= 1ms
        use                 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 further iterate
        DBQuery.shellBatchSize = x   set default number of items to display on shell
        exit                         quit the mongo shell
>
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条