要配置mongodb的账户密码,以及可以远程连接,mongodb安装在阿里云服务器上面
所有的安装做好
此时应该是不能远程连接,此时要先设置数据库对应的用户.
在做这些前要保证用户可以正常登陆
mongo
use admin
db.createUser({user:"admin",pwd:"password",roles:["root"]});
先创建对应的数据库,比如说给leanote库添加用户
use leanote;
db.createUser({user: "leanote", pwd: "password", roles: [{ role: "dbOwner", db: "leanote" }]})
搞完上面的,直接去打开mongod.conf
:
修改其配置文件
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0
#bindIp: 127.0.0.1
#processManagement:
security:
authorization: enabled
主要是修改一个端口号, 另一个是打开权限校验
接着重启数据库
service mongod restart
完事儿了