Mongodb远程登陆

欢迎访问我的个人博客网站:http://www.yanmin99.com/

一、Mongodb远程登陆

  • 1、找到Mongodb的配置文件mongodb.conf,通过yum安装的话,应该是存放在/etc/mongodb.conf中,如果没有找到,可以通过find / -name mongodb.conf查找
  • 2、编辑mongodb.con文件,查找bind_ip的值是127.0.0.1,这是默认只能本机连接,修改为,0.0.0.0,表示所有机器都可以连接。
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0  # Listen to local interface only, comment to listen on all interfaces
  • 3、Mongodb远程登陆实例,mongo 远程主机ip或DNS:MongoDB端口号/数据库名 -u user -p password
yanmin:~ yanmin$ mongo 10.121.215.67:27017/admin  -uroot  -p123456
MongoDB shell version v3.4.6
connecting to: mongodb://10.121.215.67:27017/admin
MongoDB server version: 3.4.6
Server has startup warnings:
2017-08-04T16:00:16.065+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-08-04T16:00:16.065+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2017-08-04T16:00:16.065+0800 I CONTROL  [initandlisten]
MongoDB Enterprise > show databases;
admin             0.000GB
bill              0.010GB
cc                0.002GB
cc_data_20140728  0.000GB
local             0.000GB
weixin            0.000GB
MongoDB Enterprise >

推荐阅读更多精彩内容