- 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.
推薦閱讀
- Mastering Ext JS(Second Edition)
- 基于粒計算模型的圖像處理
- Microsoft Dynamics 365 Extensions Cookbook
- RTC程序設計:實時音視頻權威指南
- Python GUI Programming Cookbook
- SharePoint Development with the SharePoint Framework
- 精通Python自動化編程
- 硅谷Python工程師面試指南:數據結構、算法與系統設計
- Illustrator CC平面設計實戰從入門到精通(視頻自學全彩版)
- 黑莓(BlackBerry)開發從入門到精通
- Data Manipulation with R(Second Edition)
- 系統分析師UML用例實戰
- Django 2.0 入門與實踐
- C++面向對象程序設計教程
- Unity3D高級編程:主程手記