1、首先修改mongodb的配置文件 让其监听所有外网ip

 

编辑文件:/etc/mongodb.conf

修改后的内容如下:

    bind_ip = 0.0.0.0

    port = 27017

   auth=true

2、/etc/init.d/mongodb restart

3、连接

#本地连接

/usr/local/mongodb/bin/mongo
 
#远程连接
 
/usr/local/mongodb/bin/mongo 127.0.0.1/admin -u username -p password
4、给某个数据库添加用户访问权限
  db.addUser('user','pwd')
  db.auth('user','pwd')
5、删除用户
db.removeUser('username')

相关文章:

  • 2021-08-19
  • 2022-01-12
  • 2022-01-05
  • 2021-12-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-13
  • 2022-02-14
  • 2021-12-19
  • 2021-08-08
  • 2021-05-26
  • 2021-07-01
  • 2021-11-26
相关资源
相似解决方案