- MongoDB Administrator’s Guide
- Cyrus Dasadia
- 198字
- 2021-07-02 15:47:42
How to do it...
- Find your system's network interfaces and corresponding IP address(s) using the ifconfig command. For example, let's assume your system's IP address is 192.168.1.112.
- Start the mongod daemon without any special flags:
mongod --dbpath /data/db
This starts the mongod daemon which binds to all network interfaces on port 27017.
- In a separate Terminal, connect to your MongoDB server on this IP:
mongo 192.168.1.112:27017
You should see a MongoDB shell.
- Now stop the previously running mongod daemon (press Ctrl + C in the Terminal) and start the daemon to listen to your loopback interface:
mongod --dbpath /data/db --bind_ip 127.0.0.1
- In a separate Terminal, connect to your MongoDB server on this IP:
mongo 192.168.1.112:27017
- This time the mongo client will exit with a connect failed message. Let's connect to your loopback IP and it should work:
mongo 127.0.0.1:27017
- Stop the mongod daemon (press Ctrl + C in the Terminal) and let's start the daemon such that it binds to a different port as well:
mongod --dbpath /data/db --bind_ip 127.0.0.1 --port 27000
- In a separate Terminal, connect to your MongoDB server on this IP:
mongo 127.0.0.1:27000
- You should be connected to the server and see the mongo shell.
推薦閱讀
- Instant Testing with CasperJS
- jQuery Mobile Web Development Essentials(Third Edition)
- Java程序設計實戰教程
- Python從小白到大牛
- OpenNI Cookbook
- Learning Hunk
- Mastering ROS for Robotics Programming
- ASP.NET程序開發范例寶典
- Couchbase Essentials
- Apache Camel Developer's Cookbook
- Android Game Programming by Example
- Python編程快速上手2
- 實驗編程:PsychoPy從入門到精通
- 從零開始學Unity游戲開發:場景+角色+腳本+交互+體驗+效果+發布
- Isomorphic Go