本文介绍的内容是关于 MongoDB 远程访问 配置 ,下面话不多说,直接来看看详细的步骤。
1、首先修改mongodb的配置文件 让其监听所有外网ip
编辑文件: /etc/mongodb.conf
修改后的内容如下:
1 2 3 4 5 |
bind_ip = 0.0.0.0
port = 27017
auth=true |
2、 /etc/init.d/mongodb restart
3、连接
1 2 3 4 5 6 7 |
#本地连接
/usr/local/mongodb/bin/mongo
#远程连接
/usr/local/mongodb/bin/mongo 127.0.0.1/admin -u username -p password |
4、给某个数据库添加用户访问权限
1 2 |
db.addUser( 'user' , 'pwd' ) db.auth( 'user' , 'pwd' ) |
5、删除用户
1 |
db.removeUser( 'username' ) |
总结
以上就是关于mongodb远程访问配置的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流。
查看更多关于MongoDB远程访问配置步骤详解的详细内容...