- 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.
推薦閱讀
- Embedded Linux Projects Using Yocto Project Cookbook
- Cocos2D-X權威指南(第2版)
- Node.js Design Patterns
- 騰訊iOS測試實踐
- 秒懂設計模式
- Quarkus實踐指南:構建新一代的Kubernetes原生Java微服務
- The Data Visualization Workshop
- HTML5 APP開發(fā)從入門到精通(微課精編版)
- JavaScript應用開發(fā)實踐指南
- ASP.NET開發(fā)寶典
- C語言程序設計教程
- C語言編程魔法書:基于C11標準
- 開源網絡地圖可視化:基于Leaflet的在線地圖開發(fā)
- 熱處理常見缺陷分析與解決方案
- Getting Started with Hazelcast