如何使用批处理脚本连接mongodb远程服务器

时间:2019-12-19 05:01:54

标签: node.js mongodb batch-file scheduled-tasks

我正在尝试使用批处理脚本连接到MongoDB远程服务器以更新集合:

cd Program Files\MongoDB\Server\3.0\bin
mongo.exe 
mongo.exe --eval "use mydb"
pause

如果数据库位于本地计算机中,我找到了解决方案。我找不到用于远程服务器的任何正确解决方案。 请帮助我找到解决方案。

1 个答案:

答案 0 :(得分:1)

  

假设您只想连接到MongoDB服务器并打开mongoshell

您需要安装mongoshell才能连接到远程MongoDB。 Here是更多详细信息。

您可以使用--username--password选项使用特定的用户凭据进行连接。

您可以参考this来了解如何使用mongoshell。