mongodb开启鉴权之后,不输入密码账号依然可以执行数据库操作。

mongodb开启鉴权之后,只有第一次需要输入用户名密码,之后关闭服务重新开启,执行数据库操作就不需要输入用户名密码了。应该如何解决呢?
谢谢~

阅读 4.1k
1 个回答

mongodb服务器还需要在启动时加一个auth参数,文档中这样写

Run the database (mongod process) with the --auth option to enable security. You must either have added a user to the admin db before starting the server with --auth, or add the first user from the localhost interface.

我也觉得这个设计很奇怪,为啥不直接缺省带上呢。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进