0%

安全配置

安全配置

  1. 进入mongo命令行
1
2
mongo
use admin
  1. 分别创建 管理员|读写|读 用户
1
2
3
4
5
db.createUser({ user:"cbimadmin", pwd: "Admin@cbim", roles:[ { role: "__system", db: "admin" },{role:"root", db:"admin"}]})

db.createUser({ user:"cbimw", pwd: "Write@cbim", roles:[ { role:"readWriteAnyDatabase", db: "admin" } ]})

db.createUser({ user:"cbimr", pwd: "Read@cbim", roles:[ { role: "readAnyDatabase", db: "admin" } ]})
  1. 修改监听地址和端口
1
vim /etc/mongod.conf
net:
    port: 27017             #修改端口
    bindIp: 127.0.0.1  #修改为本地ip
  1. 安全认证启动
1
mongod  --config /etc/mongod.conf --auth