我正在尝试将本地mongodb数据导出到Atlas集群,并创建了转储,现在我正在使用命令,
mongorestore --host Cluster0-shard-0/cluster0-shard-00-00-qwo7v.mongodb.net:27017,cluster0-shard-00-01-qwo7v.mongodb.net:27017,cluster0-shard-00-02-qwo7v.mongodb.net:27017 --ssl --username username --password <PASSWORD> --authenticationDatabase admin
尝试还原它,但给我系统找不到指定的文件。但是,如果我键入mongorestore,那么它可以工作,但是无论如何它都不会还原到Atlas云服务器。我究竟做错了什么?
编辑:我使用的路径是C:\ Program Files \ MongoDB \ Server \ 4.2 \ bin \ dump \ gfg和dump \ gfg,但它仍然无法正常工作。
独立的MongoDB
使用mongorestore时,需要提供您需要还原的文件/转储的位置
mongorestore --host=mongodb1.example.net --port=27017 --username=user --authenticationDatabase=admin /opt/backup/mongodump-2011-10-24
缺少命令的最后一部分,该部分定义了需要还原的数据的位置。
复制集
要在副本服务器上还原MongoDB,您必须停止mongod并将文件替换为mongodb。请阅读此处以在副本集上还原数据库。
为了从独立还原到副本,
mongorestore --host myReplSet/mongo0.example.com:27020,mongo1.example.com:27012 --db <dbname> <folder_location>
如果仍然不起作用,请检查路径并确保其正确转义(名称中的空格)或带引号。
您的代码带有引号和路径:
mongorestore --host Cluster0-shard-0/cluster0-shard-00-00-qwo7v.mongodb.net:27017,cluster0-shard-00-01-qwo7v.mongodb.net:27017,cluster0-shard-00-02-qwo7v.mongodb.net:27017 --ssl --username username --password <PASSWORD> --authenticationDatabase admin "C:\Program Files\MongoDB\Server\4.2\bin\dump\gfg"
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句