简体   繁体   English

将mongo数据库复制到本地

[英]copying mongo database to local

I need to copy a mongo database from my Mongo Cloud Atlas and use it with my meteor app locally, but after doing the following steps, db.users.find().count() still reports the "older" database count not the new one I thought I correctly restored after mongodump. 我需要从Mongo Cloud Atlas复制一个mongo数据库,并在本地与我的流星应用程序一起使用,但是在执行以下步骤之后, db.users.find().count()仍然报告“较旧的”数据库计数而不是新的我以为我在mongodump之后正确恢复了。 Any ideas? 有任何想法吗?

dump from the Atlas cluster, run from the app parent directory: 从Atlas集群转储,从应用程序父目录运行:
mongodump --host Cluster0-shard-0/cluster0-shard-00-00-oko1k.mongodb.net:27017,cluster0-shard-00-01-oko1k.mongodb.net:27017,cluster0-shard-00-02-oko1k.mongodb.net:27017 --ssl --username myname --password myPswd --authenticationDatabase admin --db dbName

Terminal reports lines like: 终端报告如下行:
2018-03-17T05:03:57.462+1100 writing dbName.tempLinksGroupsCol to 2018-03-17T05:03:57.465+1100 done dumping dbName.commonCol (1 document)

Confirm the presence of a dump directory which contains a directory "dbName". 确认存在包含目录“ dbName”的转储目录。

copy data from newly dumped dbName to my local dbName by running this command from the app parent directory: 通过从应用程序父目录运行以下命令,将数据从新转储的dbName复制到我的本地dbName:

mongorestore --maintainInsertionOrder -h 127.0.0.1 --port 3001 --drop -d dbName dump/dbName

I get lines like: 我得到这样的行:
2018-03-17T05:21:48.826+1100 finished restoring dbName.cronHistory (0 documents) 2018-03-17T05:21:48.826+1100 done switch to the app directory and run the command: 2018-03-17T05:21:48.826+1100 finished restoring dbName.cronHistory (0 documents) 2018-03-17T05:21:48.826+1100 done切换到app目录并运行命令:
meteor open a new terminal and run the command: meteor打开一个新的终端并运行命令:
meteor mongo

issue the command from the mongo shell: 从mongo shell发出命令:
db.users.find().count()

Still reports the old count not the new one from the restored database. 仍然报告已还原数据库中的旧计数而不是新计数。

try: 尝试:

mongorestore -h 127.0.0.1 --port 3001 --drop

I see that you are not providing correct path of dump. 我发现您没有提供正确的转储路径。 just mention path of dump folder. 仅提及转储文件夹的路径。

See documentation for mongorestore https://docs.mongodb.com/manual/reference/program/mongorestore/ 请参阅mongorestore的文档https://docs.mongodb.com/manual/reference/program/mongorestore/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM