本文介绍了设置密码到流星的mongo数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在舞台服务器中部署了一个流星项目,两天前我发现mongodb没有密码.我只提供IP(没有用户名,没有密码)就可以用robomongo连接到mongodb.

I have deployed a meteor project in a stage server and 2 days ago I found out mongodb had no password. I was able to connect to mongodb with robomongo by only providing the IP(no username, no password).

我想设置一个密码来保护它.我一直在关注文档,但我收到了"mongo/mongod不是命令在应用程序的根目录中或在"meteor mongo"命令之后写入这些命令.

I want to set a password to protect it. I have been following this documentation but I get "mongo/mongod not a command" when writing these commands in application's root directory or after "meteor mongo" command.

我在这里缺少什么,如何使用密码保护mongodb?

What am I missing here, how can I protect mongodb with a password?

谢谢

推荐答案

运行Meteors内置MongoDB服务器时,我认为您无法做到.

I don't think you can, when you are running Meteors built-in MongoDB server.

这样做的原因是,如果您在该数据库上输入密码,Meteor将无法连接到该数据库.

The reason for this is that if you put a password on that database, Meteor will not be able to connect to it.

要在MongoDB连接中指定密码,您需要设置MONGO_URL环境变量.

And to specify a password in the MongoDB connection you need to set the MONGO_URL environment variable.

当您执行此操作时,Meteor会认为您正在运行外部MongoDB安装,甚至不会启动内置的MongoDB服务器.

And when you do that Meteor will think you are running an external MongoDB installation and it will not even start the built-in MongoDB server.

所以这有点像22.

要设置密码,您需要在服务器上安装一个单独的MongoDB,在该服务器上设置一个密码,然后使用MONGO_URL环境变量使用以下格式告诉Meteor使用它:

To set a password you need to have a separate MongoDB installed on your server, set a password on that one, and then tell Meteor to use it using a MONGO_URL environment variable in the format:

mongodb://username:password@127.0.0.1:27017/meteor

请参见 https://docs.meteor.com/api/collections.html#mongo_url

这篇关于设置密码到流星的mongo数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 23:28
查看更多