Raspberry Pi mongodb combat

1. Installation

      1. Install mongodb

              sudo apt-get install mongodb

      2. Start the service

                   mongod --dbpath /home/pi/mongod_data/

      3. Start the command line

                   mongo 

                   At this point you can see that the version is MongoDB shell version: 2.4.14


Two, placement

     1. Configure the host ip:

               sudo vim /etc/mongodb.conf

               Join as follows: 127.0.0.1, own ip

     2. Configure the firewall to allow the LAN environment to access the database

               2.1 Installation: sudo apt-get install ufw

               2.2 Enable: sudo ufw enable

               2.3 Forbid external access sudo ufw default deny

               2.4 Enable LAN mongodb port access: sudo ufw allow from 192.168.0.0/8 


3. Use

     1.pymongo download

                 Note here that the latest version of pymongo is not compatible with MongoDB 2.4, so remember to download the old version when downloading

                       pip install pymongo==3.1.1

      2. Use

                       It is very convenient to use: connect, close, add, delete, modify and check. For specific operations, see the official website documentation:

                       http://api.mongodb.com/python/current/index.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325754346&siteId=291194637