【问题标题】:How to export/push my local database in MongoDB atlas如何在 MongoDB 地图集中导出/推送我的本地数据库
【发布时间】:2019-08-08 22:24:24
【问题描述】:

我在本地机器上有一个数据库,我在 MongoDB atlas 中创建了一个集群并连接它。我想将我的数据库导出/推送到集群。我使用此命令创建了我的数据库转储 mongodump --db all_product --collection product

My database:
    > show dbs
    admin        0.000GB
    all_product  0.000GB
    config       0.000GB
    local        0.000GB
    > use all_product
    switched to db all_product
    > show collections
    product
    > db.product.count()
    522

我使用这个命令尝试了二进制导出 mongorestore:

C:\Windows\system32>mongorestore --host allProducts-shard-0/allproducts-shard-00-00-k6ufl.mongodb.net:27017,allproducts-shard-00-01-k6ufl.mongodb.net:27017,allproducts-shard-00-02-k6ufl.mongodb.net:27017 --ssl --username shakib --password <testpass> --authenticationDatabase admin

但我收到此错误 - 系统找不到指定的文件

如何设置文件路径或者我应该怎么做。我的 mongo DB 文件存储在 C:\data\db

【问题讨论】:

  • 您是否尝试过指定数据库文件路径?至少对于一个集合,我使用 cmd :mongorestore -h "your_host" -d "your db" -c "your-collection" -u &lt;user&gt; -p &lt;password&gt; collection.bson 所以它应该是相似的
  • 您可以尝试添加--file \c\data\db 还是添加cd C:data\db 然后执行您的命令。
  • 我都试过了,但我得到了同样的错误@ViharManchala
  • 那不是工作伙伴@lalam
  • 您使用的 mongodump 命令应该在目录中创建一个转储文件夹。你能看到吗?

标签: python database mongodb database-connection


【解决方案1】:

您需要使用 --dir 明确指定目录的名称。
参考下面的代码

mongorestore --ssl --host <host> --authenticationDatabase admin --dir="<dumpDirectory>" -u <adminUserName> --password <password>

<host>: get from mongo atlas dashboard (click on the cluster name) ex: cluster0-shard-00-00-cbei2.mongodb.net:27017 
<dumpDirectory>: The folder where database is dumped using mongodump
<adminUserName>: admin User for that database
<password>: admin associated password

【讨论】:

    猜你喜欢
    • 2021-04-10
    • 2023-04-11
    • 1970-01-01
    • 2020-11-08
    • 1970-01-01
    • 2021-08-06
    • 2015-10-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多