使用mongodb成功导入后未显示新集合

时间:2015-10-18 15:20:39

标签: mongodb openshift

知道为什么collection没有显示在结果中?我已将lastmanstanding设为当前db

[host repo]\> mongoimport --db $OPENSHIFT_APP_NAME --collection players --drop --host $OPENSHIFT_MONGODB_DB_HOST --port $OPENSHIFT_MONGODB_DB_PORT --username $OPENSHIFT_MONGODB_DB_USERNAME  --password $OPENSHIFT_MONGODB_DB_PASSWORD --file db/primer-dataset-players.json --jsonArray
connected to: 127.2.202.130:27017
Sun Oct 18 11:15:19.789 dropping: MyDatabaseName.players
Sun Oct 18 11:15:19.796 imported 3 objects
[lastmanstanding-bobbyrne01.rhcloud.com repo]\> mongo
MongoDB shell version: 2.4.9
connecting to: 127.2.202.130:27017/admin
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
    http://docs.mongodb.org/
Questions? Try the support group
    http://groups.google.com/group/mongodb-user
> set MyDatabaseName
set MyDatabaseName to true
> show collections
system.indexes
system.users

db/primer-dataset-players.json的内容..

[
    {
        "name": "bobbyrne01",
        "id": 21
    },
    {
        "name": "Someone",
        "id": 55
    }
]

1 个答案:

答案 0 :(得分:0)

设置当前数据库的命令是use而非set。有关文档,请参阅here

所以它应该是:

> use MyDatabaseName

而不是

> set MyDatabaseName