简体   繁体   English

如何使用pymongo从受密码保护的Mongo Server复制数据库?

[英]How to copy database from password protected Mongo Server using pymongo?

I am trying to copy a database from a Mongo Server to my local Mongo instance. 我试图将数据库从Mongo Server复制到我的本地Mongo实例。

I need to do this through python and am running Pymongo 3.4 , which doesn't have the copy_database method anymore. 我需要通过python来执行此操作,并正在运行Pymongo 3.4 ,该方法不再具有copy_database方法。 Instead, I have tried using the client.admin.command('copydb', ...) function instead. 相反,我尝试使用client.admin.command('copydb', ...)函数代替。 However, seems that it does not support authentication of the source Mongo Server anymore. 但是,似乎它不再支持源Mongo Server的身份验证。

Are there any workarounds to this? 有什么解决方法吗?

Thanks 谢谢

Are there any workarounds to this? 有什么解决方法吗?

As mentioned on the comments, there is currently no workaround to copy an authenticated source MongoDB server to another server via PyMongo (version 3.4) 如评论所述,目前尚无解决方法可通过PyMongo (版本3.4)将经过身份验证的源MongoDB服务器复制到另一台服务器。

For more explanation on the reason behind it, please read Blog: PyMongo's 'copy_database' 有关其背后原因的更多说明,请阅读博客:PyMongo的“ copy_database”

Depending on the requirements, you could utilise mongo shell method db.copyDatabase() to copy from one mongod to another. 根据需求,您可以使用mongo shell方法db.copyDatabase()从一个mongod复制到另一个mongod

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

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