MongoDB:服务器有启动警告

mei*_*iyl 21 windows mongodb

我今天首先安装了MongoDB 3.2.5.但是当我启动它并使用MongoDB shell时,它给了我以下警告:

C:\Windows\system32>mongo
MongoDB shell version: 3.2.5
connecting to: test
Server has startup warnings:
2016-04-16T11:06:17.943+0800 I CONTROL  [initandlisten]
2016-04-16T11:06:17.943+0800 I CONTROL  [initandlisten] ** WARNING: Insecure configuration, access control is not enabled and no --bind_ip has been specified.
2016-04-16T11:06:17.943+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted,
2016-04-16T11:06:17.943+0800 I CONTROL  [initandlisten] **          and the server listens on all available network interfaces.
2016-04-16T11:06:17.943+0800 I CONTROL  [initandlisten]
>
Run Code Online (Sandbox Code Playgroud)

我的操作系统是Microsoft Windows [版本10.0.10586].

Lak*_*age 32

您尚未在Mongodb中配置安全功能,如授权和身份验证.使用此链接获取更多详细信息.如果你要学习Mongodb,你可以忽略这一点.但是当产品进入生产水平时.你应该关注他们.您可以使用mongod --auth启用访问控制.

例如,你可以运行mongod --auth --port 27017 --dbpath /data/db1.之后,您可以使用用户名和密码保护数据库.

您可以使用以下命令在数据库中添加用户.

use admin
db.auth("myUserAdmin", "abc123" )
Run Code Online (Sandbox Code Playgroud)

之后,您可以使用mongo --port 27017 -u "myUserAdmin" -p "abc123" --authenticationDatabase "admin"连接到数据库.

您可以bind_ip按如下方式添加mongod.conf,

`bind_ip = 127.0.0.1,192.168.161.100` 
Run Code Online (Sandbox Code Playgroud)

如果需要,您可以定义许多.这个bind_ip选项告诉MongoDB接受来自哪个本地网络接口的连接,而不是"远程IP地址".并且运行mongod --config <file path to your mongod.conf> 完全可以运行mongod --auth --port 27017 --dbpath /data/db1 --config <file path to your mongod.conf>